class x public static void mainString args System
แสดงผลทางจอภาพ class x} public static void main(String args}([] System. out. println("burin"); System. out. println("rujjanapan"); String s = "thaiall"; System. out. println(s + s. length()); } } http: //www. thaiall. com/class Page: 3
เลอกดวย IF (1/4) class x} public static void main(String args}([] int x; x = 6; if (x > 5 ( System. out. println("value: " + x; ( { { http: //www. thaiall. com/class Page: 5
เลอกดวย IF (2/4) class x} public static void main(String args}([] int x; x = 6; if (x > 5} ( System. out. print("value; (": System. out. print(x; ( { { { http: //www. thaiall. com/class Page: 6
เลอกดวย IF (3/4) class x} public static void main(String args}([] int x; x = 6; if (x > 5 && x < 10 ( System. out. println("five to ten; (" if (x > 5 || x < 10 ( System. out. println("all numbers; (" if (x > 10( System. out. println("more than 10; (" System. out. println(x; ( { { http: //www. thaiall. com/class Page: 7
เลอกดวย IF (4/4) class x} public static void main(String args}([] int x = 3; if (x > 5 ( System. out. println("1; (" else} System. out. println("less than 5; (" System. out. println("or equal 5; (" { { { http: //www. thaiall. com/class Page: 8
เลอกดวย SWITCH (1/2) class x} public static void main(String args}([] byte wow = 3 ; switch (wow} ( case 1 : System. out. println("one"); break; case 2 : System. out. println("two"); break; case 3 : System. out. println("three ; (" break ; { { { http: //www. thaiall. com/class Page: 9
เลอกดวย SWITCH (2/2) import java. util. Date; class x} public static void main(String args} ([] byte oho=(byte)(new Date(). get. Time() % 5 ; ( switch (oho} ( case 1 : System. out. println("one"); break; case 2 : System. out. println("two"); break; default: System. out. println("not found" + a; ( break ; { { { http: //www. thaiall. com/class Page: 10
ทำซำดวย for (1/2) class x} public static void main(String args}([] for (int i=0; i<10; i} (++ System. out. println(i; ( { for (int i=9; i>=0; i} (-System. out. println(i; ( { { { http: //www. thaiall. com/class Page: 12
ทำซำดวย for (2/2) class x} public static void main(String args}([] System. out. println("ASCII; (": for (int i=0; i<256; i++) { //0 -255 System. out. print((char)i ; (" " + { String s = "thaiall; " System. out. println(s + s. length ; (() { { http: //www. thaiall. com/class Page: 13
ทำซำดวย while (1/2) class x} public static void main(String args}([] int i; i = 1; while (i <= 5} ( System. out. println(i ; ( i; ++ { { { http: //www. thaiall. com/class Page: 14
ทำซำดวย while (2/2) class x} public static void main(String args}([] { int i = 0; do} System. out. println(i; ( i; ++ while (i <= 10 ; ( { { http: //www. thaiall. com/class Page: 15
- Slides: 15