Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Object or Literal

 
RAGU KANNAN
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folk's

From the following statment the String has literal value or object reference? Pls advice me.

Thanks, Raghu.K


Long x = new Long("10");
String s1 = x.toString();
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s1 refers to a String object. It is not the same object as the String literal "10".

How do I know?
1. I read the API
2. I wrote a test program based on your code.

Total time 5 minutes (including this post).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic