Содержание
- 2. Comments /* . . . */ - multi line comment // . . . - single-line
- 3. How to Use Comments Comments should be used to give overviews of code and provide additional
- 4. Variables Variables declaration: int k; double x = 2.1; Local variable should be initialized before it
- 5. 1. What will this program output? public class InitTest { public static void main (String[] args)
- 6. 2. What will this program output? public class Oblzm { public static void main (String args[]){
- 7. 3. What will this program output? public class Oblzm { public static void main (String args[]){
- 8. 4. What will this program output? public class Oblzm { public static void main (String args[]){
- 9. Constant Declaration final modifier: final int a = 42; // a = 12; - compile error
- 10. If-Then_Else Statement I if (boolean_expression) { statements } if (boolean_expression) { statements } else { statements
- 11. If-Then_Else Statement II if (boolean_expression) { statements; } else if (boolean_expression) { statements; } else if
- 12. If-Then-Else Example int a = 10; if (a > 0) { System.out.println("Positive"); } else if (a
- 13. Switch Statement switch(integral-expression) { case integer-value1 : statements; case integer-value2 : statements; break; case integer-value3 :
- 14. Switch Example char c = ’b’; switch(c) { case ’a’: case ’e’: case ’i’: case ’o’:
- 15. Switch Statement Expressions You can use enumerations as switch expression and case values You can use
- 16. While and Do-While Statement while (boolean_expression) { statements; } do { statements; } while (boolean_expression); *
- 17. While Example double a = 100.; while (a >= 1) { System.out.println(a); a /= 2.; }
- 18. Do-While Example double a = 0.5; do { System.out.println(a); a /= 2.; } while (a >=
- 19. For Statement for (initialization; Boolean-expression; step) { statements; } * Infopulse Training Center
- 20. For Examples for (int i = 10, k = 20; i System.out.println(i + " " +
- 21. Break and Continue Statements break quits the loop without executing the rest of the statements in
- 22. Use Break with a Label L: for … { for…{ break L; } } * Infopulse
- 23. Exercise 2.2.1. Find and print all divisors of a given natural number n. * Infopulse Training
- 24. Exercise 2.2.1. See 221Divisors project for the full text. * Infopulse Training Center
- 25. Exercise 2.2.2. Find and print all prime divisors of a given natural number n. * Infopulse
- 26. Exercise 2.2.3. Find sum of an infinite row for a given x Compare result with a
- 28. Скачать презентацию