GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Null string ..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Null string ....." Watch "Null string ....." New topic
Author

Null string .....

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
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 ]

Narasimha
Ryan Wilson
Ranch Hand

Joined: Apr 16, 2003
Posts: 65
narasimha
String
public String()Initializes a newly created String object so that it represents an empty character sequence.

String API
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Null string .....