Files
javaSE-0419/day08/src/com/inmind/string01/Demo03.java

27 lines
1.0 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind.string01;
/*
常用类_String的比较的方法_equals_equalsIgnoreCase
String引用数据类型的比较
==表示比较String对象的地址其实没有任何意义==一般用于基本数据类型的值是否相等比较
equals表示比较String对象地址所指向的内容
比较的方法:
public boolean equals (Object anObject) :将此字符串与指定对象进行比较。
public boolean equalsIgnoreCase (String anotherString) :将此字符串与指定对象进行比较,忽略大小
写。
*/
public class Demo03 {
public static void main(String[] args) {
String s1 = "hello";
String s2 = new String("hello");
System.out.println(s1 == s2);//比较地址 false
System.out.println(s1);
System.out.println(s2);
System.out.println(s1.equals(s2));//比较内容 true
System.out.println("-----------------------");
String s3 = "HeLlo";
System.out.println(s1.equalsIgnoreCase(s2));//true
}
}