其他分享
首页 > 其他分享> > 标准if-else语句(二选一)

标准if-else语句(二选一)

作者:互联网

public class Demo02If{
	public static void main(String[] args){
		System.out.println("It's sunny, I'm walking, and suddently I found a place...");
		int age = 16;
		if (age>=18){
			System.out.println("then I walk into the cybercafe, and start to play videogames");
			
		}
		System.out.println("then I go home");
		
	}
}



//标准的if-else 语句
public class Demo03IfELse{
	public static void main(String[] args){
		int num=6;
		
		
		if(num%2==0){// 如果除以2能够余数为0, 说明是偶数
			System.out.println("偶数");
		}else{
			System.out.println("奇数");
			
			
		}
	}
}

标签:语句,int,System,else,println,二选,public,out
来源: https://blog.csdn.net/weixin_34273095/article/details/113782505