Hi Ben,
>involves 0 object creations... surely just doing out.print ("some string")
>has to instantiate an object? Otherwise what gets passed to the function? I
>didn't think that strings could just exist outside of an object, or am I
>missing something there?
>
While paul's ( and other answers ) should pretty much have clarified
things, I wanted to add:
String literals are actually objects. See the String API:
-------------------------------------------------
The String class represents character strings. All string literals in Java
programs, such as "abc", are implemented as instances of this class.
...
String c = "abc".substring(2,3);
...
The Java language provides special support for the string concatentation
operator ( + ), and for conversion of other objects to strings. String
concatenation is implemented through the StringBuffer class and its append
method.
-------------------------------------------------
Secondly, copies are sent to methods, but for non-primitives, they are
copies of object references. Turns out that we really rarely ( I'll leave
that hole open ) deal with objects themselves, we are always dealing with
object references. In the case of literals, I assume ( here we go... ) that
there is an internal hidden reference that is copied as an argument to the
method. Therefore, no object instantiation. Literals are interned anyway,
there is only ever one instance of a literal.
Joe Sam Shirah
Autumn Software
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html