1 / 14

Valdymo struktūros 2

Valdymo struktūros 2. While ciklas. while (expression) { // do stuff } or int x = 2; while(x == 2) { System.out.println(x); ++x; }. while (int x = 2) { } Ar teisinga?. int x = 1; 1 while (x) { } 2 while (x = 5) 3 while (x == 5) { } 4 while (true) { }. Do ciklas. do {

kitra-wells
Download Presentation

Valdymo struktūros 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Valdymo struktūros 2

  2. While ciklas while (expression) { // do stuff } or int x = 2; while(x == 2) { System.out.println(x); ++x; }

  3. while (int x = 2) { } Ar teisinga?

  4. int x = 1; 1 while (x) { } 2 while (x = 5) 3 while (x == 5) { } 4 while (true) { }

  5. Do ciklas do { System.out.println("Inside loop"); } while(false);

  6. For each String [] sNums = {"one", "two", "three"}; for(String s : sNums) { System.out.println(s); }

  7. Break ir continue boolean problem = true; while (true) { if (problem) { System.out.println("There was a problem"); break; } } while (!EOF) { //read a field from a file if (wrongField) { continue; // move to the next field in the file } // otherwise do other stuff with the field }

  8. Žymės boolean isTrue = true; outer: for(int i=0; i<5; i++) { while (isTrue) { System.out.println(“1"); break outer; } System.out.println(“2"); } System.out.println(“3");

  9. outer: for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { System.out.println(“1"); continue outer; } System.out.println(“2"); } System.out.println(“3");

  10. Išvardijimai enum CoffeeSize { BIG, HUGE, OVERWHELMING };

  11. public class CoffeeTest1 { public static void main(String[] args) { enum CoffeeSize { BIG, HUGE, OVERWHELMING } // WRONG! Cannot // declare enums // in methods Coffee drink = new Coffee(); drink.size = CoffeeSize.BIG; } }

  12. Išimtys

  13. Klaidų šaltiniai • Kompiuteris • JRE • Vartotojo sukurta programa

More Related