Java - What is the output, compare string values

What is the output of the following code.

Description

What is the output of the following code.

public class Main{

  public static void main(String[] args) {

    String aas = "aaa";
    String bbs = "aaa";
    System.out.println(aas == bbs);
    
    
    bbs = new String("aaa");
    System.out.println(aas == bbs);
  }
}


Click to view the answer

true
false

Note

== compares the address of value

Related Topic