• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null string .....

 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When i executed the below code,
-----------------------
public class A{
public static void main (String[] args) {
String s1 = null; // 3
String s2 = new String(); // 4
String s3 = new String(); // 5
System.out.print(s1); // 1
System.out.print(s2); // 2
}
}
-------------------------
Output will be null(for line number 1 ) and there is no output for line number 2.
Can any of you explain me the difference, between declaring the string object on line numbers 3, 4 and 5. When can i use the reference of each these, can you explain me with the examples..
Thanks in Advance...
Narasimha.
[ May 16, 2003: Message edited by: narasimha rao bandlamudi ]
 
Ryan Wilson
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
narasimha
String
public String()Initializes a newly created String object so that it represents an empty character sequence.

String API
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic