without [] squire brackets.Apple, Banana, Orange
Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
scjp6-90%
armando fonseca wrote:is this a homework? or an assignment ? there is a policy about question regarding those scenario. You can use String methods, or regex if you are comfortable with it.
Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
Bhagat Singh Rawat wrote:Its homework in terms of performance, I have 3 solutions: ...
Bhagat Singh Rawat wrote:1-
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Ernest Friedman-Hill wrote:Note that there's a very easy way to double the performance of method #2 -- but I'll leave that to your imagination...
Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
SCJA
~Currently preparing for SCJP6
SCJA
~Currently preparing for SCJP6
Brian Legg wrote:I would imagine is has something to do with you calling "fruits.toString()" 2 times in the same method call. A doubling of performance would occur if you could somehow omit one
![]()
Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
fruits.toString().substring(1, fruits.toString().length - 1);
1. String str = fruits.toString();
2. str = str.substring(1, str.length - 1);
SCJP 6
David Marco wrote:
fruits.toString().substring(1, fruits.toString().length - 1);
above code appears to create three string objects "from side to side" whereas
1. String str = fruits.toString();
2. str = str.substring(1, str.length - 1);
creates two Strings. Also the first solution leaves all the three objects unreferenced on the heap (a memory wast?) whereas the last solution only leaves one unreferenced String.
Correct me if I'm wrong.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions