What is the o/p of the code blocks below and why is the difference in o/p's?
String helloWorld = "Hello, world!";
if(helloWorld=="Hello, world!"){
System.out.println("== is true");
}else{
System.out.println("== is false");
}
if(helloWorld.equals("Hello, world!")){
System.out.println(".equals is true");
}else{
System.out.println(".equals is false");
}
String helloWorld = new String("Hello, world!");
if(helloWorld=="Hello, world!"){
System.out.println("== is true");
}else{
System.out.println("== is false");
}
if(helloWorld.equals("Hello, world!")){
System.out.println(".equals is true");
}else{
System.out.println(".equals is false");
}