#How to add a ". . ." loading at the end of a string

1 messages ยท Page 1 of 1 (latest)

latent abyssBOT
#

<@&987246399047479336> please have a look, thanks.

latent abyssBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

You can achieve this by using a loop and the TimeUnit.SECONDS.sleep() method. Here's an example code snippet that adds a ". . ." loading animation at the end of a string every 3 seconds:

import java.util.concurrent.TimeUnit;

public class LoadingAnimation {
    public static void main(String[] args) throws InterruptedException {
        String text = "Loading";
        
        while (true) {
            System.out.print(text + ". . .");
            TimeUnit.SECONDS.sleep(3);
            
            // Clear the previously printed text
            for (int i = 0; i < text.length() + 4; i++) {
                System.out.print("\b");
            }
        }
    }
}

In this code, we have an infinite loop that prints the text followed by ". . ." and then sleeps for 3 seconds using TimeUnit.SECONDS.sleep(3). After sleeping, we use the backspace character (\b) to clear the previously printed text before printing it again with the loading animation.

Note: This code assumes that you are running it in a console or terminal window where the backspace character works as expected.

low hill
#

printLn is a new line each time, use regular print

#

@visual fjord

#

( but keep in mind that your freezing your program with such a way of displaying ) so its really just an illusion your making instead of a way to indicate the program might be busy

visual fjord
#

OMG TY

#

its a basic comp sci lab still much to learn

stark island
low hill
#

timeunits cals that @stark island

#

op's problem was the new line on the print command

#

@visual fjord no need to delete the post, u can close this thread with a command

visual fjord
#

oh

#

i thought i close it

low hill
visual fjord
#

closed