Re: String literal
stef wrote:
IMHO the assignment of a literal to a string class (String s =
"Hello";) is... amazing for an strongly oriented object language like
Java. I mean, In opposition to C++ (for example) Java doesn't
implement that kind of constructor (operator =)
On the other side, it seems that String s = <literal> is treated like
a primitive assignment, but... it stills a class :)
I do not see the point at all.
In Java you can assign one ref to another ref (if the types
are assignable).
String s is a ref to a String.
"Hello" is a ref to a string.
It seems very obvious to me that:
- they can be assigned
- it is the exact same thing as all other assignments
Arne
.
Relevant Pages
- Re: Java or C++?
... I would like to roughly repeat what James Gosling (Java inventor) said at a lecture I attended: Java is nice because you can work in Java everywhere now - from embedded to desktops to supercomputers and servers. ... Even python is less helpful; ... but C bogs you down with administrative stuff (try converting an int to a string; I found myself googling for an hour!). ... assignment would only do a memory copy ... (comp.lang.python) - Re: String literal
... IMHO the assignment of a literal to a string class (String s = ... In opposition to C++ Java doesn't ... a primitive assignment, but... ... (comp.lang.java.programmer) - Re: pass by reference
... focus has moved from insisting to use "by ref" in java-context ... independent of any other use of the word "reference" in a language. ... Just because Java-refs can be re-targetted by assignment? ... If Java had an operator to tell an Object ... (comp.lang.java.programmer) - Re: Help me!! Why java is so popular
... String or StringBuffer? ... keep in mind I knew NOTHING about Java. ... The language accepted it, no warnings, and thus I ... in some native assemblers you can peruse the instruction ... (comp.lang.java.programmer) - Re: question about assigning null to a reference object
... String getAuthor() ... void setAuthor ... b.setTitle("Thinking in Java 4th Edition"); ... (comp.lang.java.help) |
|