Author |
Message |
hamid14
![](http://compsci.ca/v3/uploads/user_avatars/12047066924bcf67a12efdb.png)
|
Posted: Thu Nov 18, 2010 6:22 pm Post subject: display text on the same line in a loop |
|
|
Im trying to display the int variable called number in a straight line while it is increasing. how would i do this, without going to the next line, until something else is true? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TerranceN
|
Posted: Thu Nov 18, 2010 6:33 pm Post subject: RE:display text on the same line in a loop |
|
|
What do you mean display a number in a straight line?
Also what output method are you using? System.out, hsa.Console or something else? |
|
|
|
|
![](images/spacer.gif) |
hamid14
![](http://compsci.ca/v3/uploads/user_avatars/12047066924bcf67a12efdb.png)
|
Posted: Thu Nov 18, 2010 7:47 pm Post subject: Re: display text on the same line in a loop |
|
|
im using system.out, i wanna put the new next number beside the old number on the same line |
|
|
|
|
![](images/spacer.gif) |
TheGuardian001
|
Posted: Thu Nov 18, 2010 7:51 pm Post subject: Re: display text on the same line in a loop |
|
|
I'm going to assume you're using Java, because nobody should use RTP over that.
As long as you never print a newline character, your input will continue on the same line. System.out.print() will print text without automatically appending a newline character on the end (as opposed to the println method, which does append the newline character.) When you want to go to a new line, just print a newline (\n) character.
code: |
System.out.print("This");
System.out.print("is");
System.out.print("all");
System.out.print("on");
System.out.print("one");
System.out.print("line");
|
|
|
|
|
|
![](images/spacer.gif) |
TerranceN
|
Posted: Thu Nov 18, 2010 7:53 pm Post subject: RE:display text on the same line in a loop |
|
|
You can use System.out.print() instead of System.out.println(). |
|
|
|
|
![](images/spacer.gif) |
hamid14
![](http://compsci.ca/v3/uploads/user_avatars/12047066924bcf67a12efdb.png)
|
Posted: Thu Nov 18, 2010 8:17 pm Post subject: Re: display text on the same line in a loop |
|
|
Okay, thanks guys. I was using this before, but netbeans was had errors and it showed a red line under it saying value is not initalized. lol just needed to restart netbeans lol. |
|
|
|
|
![](images/spacer.gif) |
SS1389
|
Posted: Sat Nov 20, 2010 9:42 pm Post subject: Re: display text on the same line in a loop |
|
|
System.out.print() does the job quite nicely.
If you were to type:
System.out.print("This ");
System.out.println("is a test.");
The output would be This is a test. |
|
|
|
|
![](images/spacer.gif) |
|