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));}为什么提示我void有错误,println也不对,求指点
能运行啊
“=”是string类判断地址值 equals只判断两个是不是相同的
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.equals(str2)); } }