I am trying to understand the working of System.out.println() in Java... in following 2 code snippet , why the answer is different and why it do not print "Hello: " string inside println() method ?
 public static void main(String[] args) {
        String x = "abc";
        String y = "abc";
        System.out.println("Hello:" + x == y);
        System.out.println("x.equals(y): " + x.equals(y));
        if(x == y){
            System.out.println("Hello:" + x==y);
        }
}
Answer is :
false
x.equals(y): true
false
And for second code snippet :
 public static void main(String[] args) {
        String x = "abc";
        String y = "abc";
        System.out.println( x == y);
        System.out.println("x.equals(y): " + x.equals(y));
        if(x == y){
            System.out.println(x==y);
        }
}
The answer is:
true
x.equals(y): true
true
 
     
     
    