aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String Object  or  Literal 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 "String Object  or  Literal" Watch "String Object  or  Literal" New topic
Author

String Object or Literal

RAGU KANNAN
Ranch Hand

Joined: Dec 16, 2005
Posts: 103
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

Joined: Aug 03, 2002
Posts: 7729
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).


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
 
subject: String Object or Literal