File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Difference between following two String Statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between following two String Statements" Watch "Difference between following two String Statements" New topic
Author

Difference between following two String Statements

Praveen palukuri
Ranch Hand

Joined: Feb 10, 2005
Posts: 65
hi,
can u give me exact difference between following 2 statements.

String str1 = "hai";
String str2 = new String("hello");
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

The first one refers to a String object which is created when the class is loaded. The second one creates a copy of an existing String object. The second one is a form you'll never see except on certification exams, or in code written by newbies who have learned Java by studying for those exams!


[Jess in Action][AskingGoodQuestions]
Naveen Vooka
Greenhorn

Joined: Oct 13, 2004
Posts: 25
Originally posted by Praveen palukuri:
can u give me exact difference between following 2 statements.


http://www.javaworld.com/javaforums/showflat.php?Cat=2&Board=javabeginner&Number=22223&page=1&view=collapsed&sb=5&o=&fpart=1

--------------
Naveen Vooka
www.devsquare.com
DevSquare - Online Application Development
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between following two String Statements
 
Similar Threads
Difference Between the String s = "String "; and String s = new String("String");
string object
String Intern
Difference between the two types of tostring methods?
About String