This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes String s = new String().equals( . . . . ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String s = new String().equals( . . . . )" Watch "String s = new String().equals( . . . . )" New topic
Author

String s = new String().equals( . . . . )

Mathew Kuruvilla
Ranch Hand

Joined: Nov 27, 2001
Posts: 135
public class Test{
public static void main(String argv[]){
Test h = new Test();
h.go();
}
public void go(){
String s1 = "Hello";
String s2 = null;
if (s1.equals(s2))
System.out.println(true);
else
System.out.println(false);
}
}
This is giving me "false". Shouldn't I be getting "java.lang.NullPointerException"???
parul patidar
Ranch Hand

Joined: Sep 07, 2001
Posts: 53
no. see code for equals method

[This message has been edited by parul patidar (edited December 06, 2001).]
Mathew Kuruvilla
Ranch Hand

Joined: Nov 27, 2001
Posts: 135
Muchas Gracias Senor!
Dhanyawadh Guruji!
Thank you Sir!
 
wood burning stoves
 
subject: String s = new String().equals( . . . . )