| Author |
doesn't print the statement in System.out.println
|
Raju Sri
Ranch Hand
Joined: Mar 10, 2004
Posts: 108
|
|
Hi all, Can any body tell me why the following code doesn't print "TO JAVA: false". -------------------------- String h1="hello"; String h2=new String("hello"); System.out.println("WELCOME"); System.out.println("TO JAVA:"+h1 == h2); System.out.println("CERTIFICATION"); ---------------------------------- I thought the program should print like below WELCOME TO JAVA:false CERTIFICATION But when I run the code it is not printing "TO JAVA" statment . Thanks in advance Raju
|
SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3<br />SCDJWS 1.4
|
 |
Vijay Pawar
Greenhorn
Joined: Sep 04, 2003
Posts: 26
|
|
Dear shrini, The rule is : Operand 1 + Operand 2 If Operand 1 is a String then + will behave as concatination operator and result will be a String "To JAVA:" + h1 == h2 will be executed as "To Java: hello" == h2 and the result u know is false Bye Jughead
|
 |
 |
|
|
subject: doesn't print the statement in System.out.println
|
|
|