+ 1

How to display text once in a loop in Java ?

In Java, how to display text once in a loop ? Example, in a countdown I want to display once the text "you have 10 seconds left." when the count arrives at 10. Is there any other solution apart from this one ? If (i==10) { System.out.println() ; } Another example Suppose that a program calculates the fall of an object and displays its speed from second to second. As soon as the object speed exceeds a given speed (10 m / s), the program displays (in addition, but only once) a message. The speed displayed is not always equal to 10m/s. Thanks for your help.

16th Jul 2020, 7:42 AM
Alexandre
Alexandre - avatar
7 Antworten
+ 3
~ swim ~ it's like codemonkey says. Thank you all.
16th Jul 2020, 9:17 AM
Alexandre
Alexandre - avatar
+ 2
Thanks you. It's work.
16th Jul 2020, 8:43 AM
Alexandre
Alexandre - avatar
0
it was not the answer I wanted. I misspoke my question. Please review my other example. Thank you.
16th Jul 2020, 8:03 AM
Alexandre
Alexandre - avatar
0
System.out.println("You have " + i + "seconds left");
17th Jul 2020, 6:25 AM
Daniel Sirius Wolf
Daniel Sirius Wolf - avatar