• Post Reply Bookmark Topic Watch Topic
  • New Topic

basic question  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I make a string repeat, say 10 times, each time on a new line, and then stop?
Thanks.
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
u can use a for loop run it 10 times and in side the statement block write
System.out.println("Your String");

System.out.println() automatically prints next string on new line so don't have to do anything for that.
regards
deekasha
 
kishor patankar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is some working code. might be help u.
import java.applet.*;
import java.awt.*;
public class Loop extends Applet
{
TextArea txtArea = new TextArea(10,30);

public void init()
{
add(txtArea);
for (int i=1; i <= 10; i++)
{
txtArea.append("Now Showing "+i+'\n');
}
}
}

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!