物件導向程式設計
|
3.1 IF流程控制(Flow Control) |
|
|
授課教師:陳慶瀚 WWW : http://www.miat.ee.isu.edu.tw/java E-mail : pierre@isu.edu.tw |
|
All but the most trivial computer programs need to make decisions. They test a condition and operate differently based on the outcome of the test. This is quite common in real life. For instance you stick your hand out the window to test if it's raining. If it is raining then you take an umbrella with you. If it isn't raining then you don't. All programming languages have some form of an Arrays have lengths and you can access that length by referencing the
variable
The arguments to a conditional statement like In Java numerical greater than and lesser than tests are done with the
{ public static void main (String args[]) { if (args.length == 0) System.out.println("Hello whoever you are"); else if (args.length == 1) System.out.println("Hello " + args[0]) else if (args.length == 2) System.out.println("Hello " + args[0] + " " + args[1]); else System.out.println("Hello " + args[0] + " " + args[1] + " " + args[2]); } } |
||
物件導向程式設計 義守大學電機系 陳慶瀚 2001.10.02 |