This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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
 
jQuery in Action, 2nd edition
 
subject: Difference between following two String Statements