实例代码如下:
//stringcompareemp.java 文件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())); }}
以上代码实例输出结果为:
-32 0 0
以上就是java 实例 - 字符串比较的内容。
