java菜鸟问题~!

来源:百度知道 编辑:UC知道 时间:2024/06/10 01:43:09
哪为大大能用 java的 if...then 语句编写一个小程序啊?有急用~!

PS:小程序就成 10行以内的 万分感谢~!

JAVA里面不支持then
只有if..else..

public class test{
public static void main(String[] asd){
bool i=true;
if(i){
System.out.print("为真");
else
System.out.print("为假");
}
}
}

JAVA没蛋

public class test{
public static void main(String[] asd){
int i=1;
if(i==1){
System.out.print("i为1");
else if(i==2)
System.out.print("i为2");
}
else{
System.out.print("i既不是1也不是2");
}
}
}