字符串比较

字符串比较

public class StringCompareEmp {//字符串比较

public static void main(String[] args) {

String str = "Hello World";

String anotherString = "hello world";

Object objStr = str;

 

System.out.println( str.compareTo(anotherString) ); System.out.println( str.compareToIgnoreCase(anotherString) );//忽略大小写

System.out.println( str.compareTo(objStr.toString()) );

}

}

 

posted @ 2021-10-04 13:29  慢漫曼蔓  阅读(20)  评论(0)    收藏  举报