A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Spring in Action
this week in the
Programmer Certification (SCJP/OCPJP)
String Object or Literal
Joined: Dec 16, 2005
Sep 17, 2006 14:19:00
From the following statment the
has literal value or object reference? Pls advice me.
Long x = new Long("10");
String s1 = x.toString();
Joined: Aug 03, 2002
Sep 17, 2006 14:44:00
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
program based on your code.
Total time 5 minutes (including this post).
Ask a Meaningful Question
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: String Object or Literal
array store exception
how many String objects are created?
When are String Literals Garbage Collected?
Using the String
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014