I recieved this comment in regards to my code: Rather than accumulating the
string, why don't you just print it as you
go along?
Here's the code:
Note: userName is used to store the name entered at the command prompt into the args[] and name is a StringBuffer to add both the userName and a space 100 times.
<code>
for( int i=0; i < 100; i++ )
{
name.append( userName + " ");
}
System.out.print( name.toString() );
</code>
Does that mean do to this:
<code>
for( int i=0; i<100; i++ )
{
System.out.print( userName );
}
</code>
In the first code I used a StringBuffer,I appended the 100 names and spaces together then I printed. I was under the impression that calling System.out.print is expensive which is why I only wanted to call on it once in my top code. Or am I just totally miss understanding what she meant (I think I am).
Thanks,
Joe