• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mathew Kuruvilla
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no. see code for equals method

[This message has been edited by parul patidar (edited December 06, 2001).]
 
Mathew Kuruvilla
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muchas Gracias Senor!
Dhanyawadh Guruji!
Thank you Sir!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic