On Aug 28, 5:55 pm, "Chrys Schock" <[EMAIL PROTECTED]> wrote:
> Notes say "String class a special class for which you can create an instance
> of it by assigning a string literal. No other class allows this form of
> object creation." To me, the Integer class (and therefore probably all the
> other wrapper classes) work the same way as the String class. What am I
> missing or misunderstanding?
I'm not sure but I think this is not absolutely comparable.
I advice you to post this question of the sun forum for beginners,
you'll get an accurate answer for sure, because in my opinion, this is
not at all a trivial question.
I mean what happens internally when you write:
Integer foo = 30;
and:
Integer foo = new Integer(30);
probably not exactly the same thing.
What is sure is that a String literal, that is "foo bar", is a
reference to an instance of class String, according to the Sun
documentation. When you write:
String foo = "bar";
This is exactly the same as:
String foo = new String("bar");
Not sure with Integer, as an int is not a reference to an instance of
class Integer.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---