Print counting in loop java -
Print counting in loop java -
i have java programme simulates values , returns them. want see how far simulation printing current state.
ex:
system.out.print("number of simulations: "); for(int i=0;i<number_of_simulations;i++){ /* calcutions*/ system.out.print("\b" + i); }
i thougth possible, output is: number of simulations: 0?1?2?3?4?5?6?7?8?9?10?11?12?
i want see current state, not counter. if i++ current removes , i+1 shown.
\b
go 1 char. pawel veselov said, utilize \r
go origin of line. of import thing that, depending on you're testing output (ide), won't work expected. should test in shell (windows cmd or linux terminal) in order see real result.
java loops printing
Comments
Post a Comment