You cannot accomplish this with System.out.print.
Instead, you need another variable to hold the text while working on it.
I would recommend using a string array (or ArrayList if you don't know how many lines will be in advance), with each entry corresponding to a line of text.
ArrayList<String> lines = new ArrayList<String>();
lines.add("|. |");
lines.add("|..|");
lines.add("| .|");
Thus, you can easily return to editing the previous line as follows:
lines.set(0, lines.get(0).concat("text to add");
Then, when you are ready to display the results:
for(String s : lines)
System.out.println(s);
source
share