Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

string object

 
arivu mathi
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Report post to moderator
String s = new String("abc");
String s = "abc";

will the above two statements create a new string object?
what is the difference between the two statements?
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by arivu mathi:
String s = new String("abc");
String s = "abc";

will the above two statements create a new string object?
what is the difference between the two statements?


I am sure that you haven't visited JAVA Ranch Properly...

Check this out..
Strings, Literally- JAVA Ranch.

This link will be usefull for you...

For more check out this also..

Java Beginners Faq
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Report post to moderator
We seem to be having a leetle problem with the bulletin board at the moment. I'm closing this one for now - it looks like a double post but it is not intentional.
 
    Bookmark Topic Watch Topic
  • New Topic