case语句

//pakage com.hisoft;
//三十而立;四十不惑;五十知天命;六十花甲;七十古稀;八十九十耄耋;一百期颐
public class Age{
	private int age;
	public Age(int yage){
	age = yage;
	}
	public void compareAge(){
	switch(age){
	case 30:{System.out.println("三十而立");
		break;
		}
	case 40:{System.out.println("四十不惑");
		break; 
		}
	case 50:{System.out.println("五十知天命");
		break; 
		}
	case 60:{System.out.println("六十花甲");
		break;
		}
	case 70:{System.out.println("七十古稀");
		break; 
		}
	default:{System.out.println("Unblievable!");
		} 
	    };
	}
	//public int getAge(){
	//return age;
	//}
	 
	public static void main(String[] args){
	int age = Integer.parseInt(args[0]);
	Age yourAge = new Age(age);
	yourAge.compareAge();
	//System.out.println(yourAge.getAge());
	}
}

你可能感兴趣的:(case)