Содержание
- 3. Условные инструкции
- 4. Условная инструкция if if (condition) true-statement if (condition) { true-statement1 true-statement2 . . . }
- 5. Условная инструкция if public class IfDemo { public static void main(String[] args) { Scanner in =
- 6. Условная инструкция if else if (condition) statement1 else statement2 if (condition) { statement_sequence1 } else {
- 7. Условная инструкция if else public class IfElseDemo { public static void main(String[] args) { Scanner in
- 8. Тернарный оператор if else condition ? expression1 : expression2
- 9. Тернарный оператор if else public class TernaryDemo { public static void main(String[] args) { Scanner in
- 10. Инструкция множественного выбора switch switch (expression) { case value1: statement_sequence1 break; case value2: statement_sequence2 break; .
- 11. Инструкция множественного выбора switch public class SwitchDemo { public static void main(String[] args) throws IOException {
- 12. Циклы
- 13. Цикл for for ( initialization ; expression ; update ){ statement1 statement2 . . . }
- 14. Цикл for public class ForDemo { public static void main(String[] args) { Scanner in = new
- 15. Цикл for Enter the number of years till retirement: 10 Enter your retirement payment: 100 Enter
- 16. Цикл “for each” или “enhanced for” for ( Type element : collectionOfType ) { statement1 statement2
- 17. Цикл “for each” или “enhanced for” public class EnhancedDemo { public static void main(String[] args) {
- 18. Цикл while while (condition) { statement1 statement2 . . . }
- 19. Цикл while public class WhileDemo { public static void main(String[] args) { Scanner in = new
- 20. Цикл while Enter your retirement goal: 1000 Enter your retirement sallary: 100 Enter interest rate: 10
- 21. Цикл do while do { statement1 statement2 . . . } while (condition);
- 22. Цикл do while public class DoWhileDemo { public static void main(String[] args) { Scanner in =
- 23. Цикл do while How much money will you contribute every year? 100 Interest rate in %:
- 24. Инструкции перехода
- 25. Инструкция break { statement_sequence1 ... if (condition) { statement_sequence2 break; } ... statement_sequence3 }
- 26. Инструкция break public class BreakDemo { public static void main(String[] args) { String[] people = {
- 27. Инструкция continue { statement_sequence1 ... if (condition) { statement_sequence2 continue; } ... statement_sequence3 }
- 28. Инструкция continue public class ContinueDemo { public static void main(String[] args) { String[] people = {
- 29. Инструкция return ... type method{ statement_sequence1 if (condition) { statement_sequence2 return [value]; } statement_sequence3 }
- 31. Скачать презентацию