Re: Drawing line on ImageIcon on panel after getting data
Lew wrote:
If you break URLs the way Jeff did, people might
helpfully suggest things like StringBuffer's and the
or StringBuilder.
evils of String addition. Explain, calmly, that this
was a hack useful for making an SSCCE, as opposed
to 'well engineered code' (which is a different thing).
Jeff's URL:
mapImage = ImageIO.read(
new URL("http://www.lib.utexas.edu/maps/" +
"cia07/australia_sm_2007.gif"));
There is no String addition here. String compile-=time constants added
together become a single compile-time constant.
<http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.28>
Huhh.. Thanks for the clarification.
Also, the effect of String addition when it does occur is likely at least
partially mitigated by
<http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.18.1.2>
"An implementation may choose to perform conversion and concatenation in
one step to avoid creating and then discarding an intermediate String object.
To increase the performance of repeated string concatenation, a Java compiler
may use the StringBuffer class or a similar technique to reduce the number of
intermediate String objects that are created by evaluation of an expression.
For primitive types, an implementation may also optimize away the creation
of a wrapper object by converting directly from a primitive type to a string"
How very clever these Sun folks are. :-)
Assuming 'may' means 'does', of course. ;-)
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200711/1