「Java入門」”==”、equalsとequalsIgnoreCaseの使い方

Javaコード
package com.kak222;
public class Huhh2 {

public static void main(String[] args) {
String c1="i am lucy";
String c2="i am lucy";
String c3="I AM LUCY";
String c4=new String(“i am lucy");
String c5=new String(“i am lucy");
String c6=new String(“I AM LUCY");
System.out.println(“c1==c2:"+(c1==c2));
System.out.println(“c1==c3:"+(c1==c3));
System.out.println(“c4==c5:"+(c4==c5));
System.out.println(“c4==c6:"+(c4==c6));
System.out.println(“c1.equals(c2)"+c1.equals(c2));
System.out.println(“c1.equals(c3)"+c1.equals(c3));
System.out.println(“c4.equals(c5)"+c4.equals(c5));
System.out.println(“c4.equals(c6)"+c4.equals(c6));
System.out.println(“c1.equalsIgnoreCase(c2)"+c1.equalsIgnoreCase(c2));
System.out.println(“c1.equalsIgnoreCase(c3)"+c1.equalsIgnoreCase(c3));
System.out.println(“c4.equalsIgnoreCase(c5)"+c4.equalsIgnoreCase(c5));
System.out.println(“c4.equalsIgnoreCase(c6)"+c4.equalsIgnoreCase(c6));

}

}
実行結果
c1==c2:true
c1==c3:false
c4==c5:false
c4==c6:false
c1.equals(c2)true
c1.equals(c3)false
c4.equals(c5)true
c4.equals(c6)false
c1.equalsIgnoreCase(c2)true
c1.equalsIgnoreCase(c3)true
c4.equalsIgnoreCase(c5)true
c4.equalsIgnoreCase(c6)true

Java

Posted by arkgame