比较运算符|关系运算符
> < >= <=
byte,short,int,long,float,double,char
== !=
基本,引用
结果都为boolean类型
*/
public class Class016_Operator{
//main方法
public static void main(String[] args){
int a = 1;
boolean flag = a>0;
System.out.println(flag);
String s1 = "zhangsan";
String s2 = "zhangsan";
System.out.println(s1==s2);
System.out.println(s1!=s2);
//练习 对下面代码进行注释
double d=10/3; //3.0
a=10/3; //3
System.out.println(a==d); //true
System.out.println(a); //3
System.out.println(d); //3.0
d=10/3.0; //3.3333
a=10/3; //3
System.out.println(a==d); //false
System.out.println(a); //3
System.out.println(d); //3.333
System.out.println("hello"!="hello"); //false
}
}
比较运算符
最新推荐文章于 2024-01-28 07:55:51 发布