K. Hodel
Posts: 8
Nickname: hodeka104
Registered: Jul, 2003
|
|
Re: Printing a String of a defined number of
|
Posted: Jul 28, 2003 1:59 PM
|
|
David's reply to your first post suggested using a StringBuffer. Here's one way to do that:
int len = 10;
StringBuffer stars = new StringBuffer();
for ( int i = 0; i < len; ++i ) {
stars.append( "*" );
}
Then, if you want to print the string, do something like
System.out.println( stars.toString() );
Using the StringBuffer also has the advantage of letting you easily change the string:
stars.setCharAt( 5, "R" );
System.out.println( stars.toString() );
|
|