java 两个字符串比较大小

参考:https://www.cnblogs.com/jimmy-muyuan/p/5989115.html

	String aaa1 = "0";//0<5
	String bbb1 = "5";//0-5 		-5
	System.out.println(aaa1.compareTo(bbb1));
	
	String aaa2 = "5";//5>0
	String bbb2 = "0";//5-0			5
	System.out.println(aaa2.compareTo(bbb2));

	String aaa3 = "5";//5==5
	String bbb3 = "5";//5-5			0
	System.out.println(aaa3.compareTo(bbb3));

java 两个字符串比较大小_第1张图片

你可能感兴趣的:(Java)