2020/10/29 -赋值运算符-比较运算符----方法入门---if else 语句

比较运算符

public class ZH5{
	public static void main(String[]args){
		System.out.println(10>5);
		int num1 = 10;
		int num2 = 20;
		System.out.println(num1<num2);
		System.out.println(num2>=100);
		System.out.println(num2<=100);
		System.out.println(num2<=12);
		System.out.println("=-=-=-=-=-=-=-=-=-=-=-=-=-=");
		
		System.out.println(10==10);
		System.out.println(20!=23);
		System.out.println(20!=20);
		
		int v = 2;
		//System.out.println(1<v,3);
		
		
	}
}

逻辑运算符

public class ZH6{
	public static void main(String[]args){
		//&&与 并且
		//|| 或
		// !非

		 System.out.println( true&&false);
		 System.out.println(3>4&&9<8);
		 System.out.println(66>55&&33<55);
		 System.out.println("+-+-+-+-+-+-+-");
		 
		 System.out.println(true||false);
		 System.out.println((8-5)>(2-1)||6>3);
		 System.out.println("==+_+_+_+===");
		 
		 System.out.println(!true);
		 
		 
		 
		 
		  
	}
}
public class SF1{
	public static void main(String[]args);
	 int a =10;
	 int b = 30;
	 int max = a > b ? a : b;
	 System.out.println("最大值:"+ max);

	 	 System.out.println(a>b ? a : b);
	 	 
}

方法在这里插入代码片

public class ff{
	public static void main (String[]args){
		farmer();
		seller(); 
		cook();
		me();
	}
	public static void farmer(){
		System.out.println("种种子");
		System.out.println("浇水");
		System.out.println("施肥");
		System.out.println("除虫");
		System.out.println("收割");
		System.out.println("出售");
	}
	public static void seller(){
		System.out.println("运输");
		System.out.println("抬高价格");
		System.out.println("卖出去");
	}
	public static void cook(){
		System.out.println("洗菜");
		System.out.println("切菜");
		System.out.println("炒菜");
		System.out.println("装盘");
	}
	public static void me(){
		System.out.println("吃");
	}
}

if else语句

public class I{
	public static void main(String[]args){
		int x = -10;
		int y;
		if (x>=3) {
			y = 2*x+1;
			
			// expression
		} else if (-3<x&&x<3) {
			y = 2* x;
			// expression
		} else {
		y = 2 *x - 1;
		}
		{
		
		}
		System.out.println(+y);
		
	} 
}
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页