2012年5月30日 星期三

Java Basic(18)-Nested if Statements


class apples{
public static void main(String args[]){
int age = 80;
if(age<50){ 如果該值小於50
System.out.println("You are young"); 將運行此statement
}else{
System.out.println("You are old"); 但如果不是
if (age>75){ 值大於75
System.out.println("You are REALLY OLD"); 將運行此statement
}else{ 但如果不是
System.out.println("You are not really that old"); 運行此statement
}
}
}
}

運行這個程序,你會看到:
You are old
You are REALLY OLD 

沒有留言:

張貼留言