• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

basic question

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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');
}
}
}

reply
    Bookmark Topic Watch Topic
  • New Topic