public class HelloWorld{ public static void main(String[] args) { int a=16; double b=9.5; String str1="hello"; String str2="imooc"; System.out.println("a等于b:" + (a==b)); System.out.println("a大于b:" + (a>b)); System.out.println("a小于等于b:" + (a<b)); System.out.println("str1等于str2:" + (str1==str2)); } }
大于小于号的问题,你的是全角字符。下面是改过之后的
int a=16;
double b=9.5;
String str1="hello";
String str2="imooc";
System.out.println("a等于b:" + (a==b));
System.out.println("a大于b:" + (a>b));
System.out.println("a小于等于b:" + (a<b));
System.out.println("str1等于str2:" + (str1==str2));
System.out.println("a小于等于b:" + (a<=b));
看看是不是用了中文标点,我用你同样的代码运行就没有错
System.out.println("str1等于str2:" + (str1.equals(str2)));
倒数第二行 应该是a<=b