Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8756125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:59:49+00:00 2026-06-13T13:59:49+00:00

Is there a way to dynamically change output in Java? For instance, in a

  • 0

Is there a way to dynamically change output in Java? For instance, in a terminal window if I have:

System.out.print("H")

and then I have:

System.out.print("I")

The output will be:

HI

Is there a way to assign a position to outputs that allows you to replace characters dynamically? For instance (and I know this would not output what I want, I merely want to demonstrate my thinking) this:

 System.out.print("H")
 Thread.sleep("1")
 System.out.print("I")

And it would first print out

H

and then after a second, replace the H with an I?

I’m sure this sounds stupid, I am just interested in dynamically changing content without GUIs. Can someone point me in the direction for this technique? Thank you very much in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:59:50+00:00Added an answer on June 13, 2026 at 1:59 pm

    You might want to take a look at

    System.out.printf
    

    Look at the example shown here: http://masterex.github.com/archive/2011/10/23/java-cli-progress-bar.html

    edit:

    printf displays formatted strings, which means you can adapt that format and change it for your needs.

    for example you could do something like:

    String[] planets = {"Mars", "Earth", "Jupiter"};        
    String format = "\r%s says Hello";
    
    for(String planet : planets) {
        System.out.printf(format, planet);
    try { 
            Thread.sleep(1000); 
        }catch(Exception e) { 
            //... oh dear
        }
    }
    

    Using the formatted string syntax found here: http://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax

    As the comment says this solution is only limited to a singular line however dependent on your needs this might be enough.

    If you require a solution for the whole screen then a possible solution would be (although quite dirty) would be to hook the operating system using JNA and get a handle on the console window, find its height and then loop println() to “clear” the window then redraw your output.

    If you would like to read more then I can answer more questions or here is a link: https://github.com/twall/jna

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to zoom in and out (dynamically change the font size,
Is there a way to dynamically change the LoginUrl of FormsAuthentication? What I have
Is there a way in C to find out the size of dynamically allocated
Is there a way in CSS or JQuery where I can dynamically change the
We have a system where we need to dynamically change what happens at the
Is there a way to dynamically change a variable value inside a string? What
Is there a way to dynamically change the size of a widget? Can an
Is there a way to dynamically determine whether the currently executing task is a
Is there any way to dynamically generate an swf file? Or insert variables after
Is there a way to dynamically set the ListId field in the ListView control.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.