increasing number

helloDoes anyone know how can i have a number to be increased ? for example:instead of 12345 like in a for(), i want the number to be changing in the same position.. not to go 1234567 and so on.. Does anybody know hoy?
[246 byte] By [River_Platea] at [2007-11-27 7:34:11]
# 1
Can you give an example of what you're talking about?
r035198xa at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 2

yeah

for example.. when you do a scandisk of your hard drive.. do you see that percentage number that goes from 0 to 100? when its 0 it changes to 1 then 2 then 3 when it reaches 9 it adds another digit, so now its 10 11 and so on but on the same place in that line.. can you get it now?

:-/

River_Platea at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 3
please tell me you're not talking about this:for(int i = 0; i <= 100; ++i) {System.out.println(i);}
Dalzhima at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 4

> please tell me you're not talking about this:

>

> [code]

> for(int i = 0; i <= 100; ++i) {

>System.out.println(i);

> /code]

No, I think he wants each subsequent printed number to overwrite the previous number. So instead of

1

2

3

4

he wants to only show one number at a time when the loop increments. The other number should disappear.

jennyFromTheBronxa at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 5

when you use a for like that right... once u start if(i < 10) for example.. then it will print like this:

0

1

2

3

and so on.. right? well i dont want it that way i want it like if it was a percentage bar when u install a program.. you have a bar that ||||||||| increases as the installation goes on.. but u also have a number inside the bar that says in numbers how the installation is going..

check this to see what i'm trying to tell :-/

http://www.java2s.com/Code/CSharpImages/ProgressBarHost.PNG

Am talking about that little number there 10%

River_Platea at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 6

> yeah

>

> for example.. when you do a scandisk of your hard

> drive.. do you see that percentage number that goes

> from 0 to 100? when its 0 it changes to 1 then 2 then

> 3 when it reaches 9 it adds another digit, so now its

> 10 11 and so on but on the same place in that line..

> can you get it now?

>

> :-/

Kinda like this?

public class PrintfTest {

public static void main(String[] args) {

for (int i = 0; i < 100; i++) {

System.out.printf("%7d", i);

try {Thread.sleep(100);} catch(InterruptedException swallowMe) {/* gulp */}

System.out.print("\b\b\b\b\b\b\b");

}

}

}

kevjavaa at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 7
Perhaps you want this: http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
r035198xa at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 8
hey thanks for that website :-D useful too.but thats not what i want :s i think jenny knowsdammit :-/ am i hard to understand? the number 0 for example.. its starts like 0% but then that 0 disappears and a 1 shows up.. later the 1 disappears and a 2 shows up.. :-/
River_Platea at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 9

> hey thanks for that website :-D useful too.

>

> but thats not what i want :s i think jenny knows

>

> dammit :-/ am i hard to understand?

Yes. No one knows whether you're talking about a javascript manipulation of a web page, a console application, or a Swing progress bar widget.

kevjavaa at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 10

lol

ok my bad!!! :-/

its a console application.. the number i want to display has to go from 0 to 100 in the same place where it is .. for example it starts with a 0, then when i increase the number, 0 is erased and 1 shows up in the same place where the 0 was..

now when you get to 9 you are about to change from a 1 digit to a 2 digit number.. 10.. this time the 0 next to the 1 will change to 1 so it will be a 11 and so on.. :-/

River_Platea at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 11

> now when you get to 9 you are about to change from a

> 1 digit to a 2 digit number.. 10.. this time the 0

> next to the 1 will change to 1 so it will be a 11 and

> so on.. :-/

So, kinda like this?

public class PrintfTest {

public static void main(String[] args) {

for (int i = 0; i < 100; i++) {

System.out.printf("%7d", i);

try {Thread.sleep(100);} catch(InterruptedException swallowMe) {/* gulp */}

System.out.print("\b\b\b\b\b\b\b");

}

}

}

kevjavaa at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...
# 12
Sorry for "hijacking" this thread...but I was wondering if there was any way to clear the console in java; so instead of using backspaces and then printing the number again, could you clear the console screen instead and then reprint the incremented number?
Josh81a at 2007-7-12 19:14:39 > top of Java-index,Java Essentials,New To Java...