Java – I can’t print on the same line (I’m not using println)

Ok, like you have probably seen by the comments on your question, many people say that you use ‘\n’ wheras this says the java console to start a new line. So to do this in just one like you have to write each line after line, so to do this better I would first of all make all the letters. For this you could use individual Arrays.
Eg:

public class teste2 {
     public static void main(String[] args) {
           // This creates T
           String[] t = new String[6];
           t[0] = "*******";
           for(int i = 1; i < t.length; i++) t[i] = "   *   ";

           // This creates E
           String[] e = new String[6];
           e[0] = "*******";
           e[1] = "*      ";
           e[2] = "****   ";
           e[3] = "*      ";
           e[4] = "*      ";
           e[5] = "*******";

           // This creates S
           String[] s = new String[6];
           s[0] = " ******";
           s[1] = "*      ";
           s[2] = " ***** ";
           s[3] = "      *";
           s[4] = "      *";
           s[5] = "****** ";

           // Now you need to print this.
           for(int i = 0; i < t.length; i++) {
                System.out.println(t[i]+"\t"+e[i]+"\t"+s[i]+"\t"+t[i]);
           }
           // This should be it.
           // You can still optimize the code and make everything in one
           // line but I think this is WAY better to read and better to
           // use as you can also use letters like the T more often.
           // BTW: this is TEST so not your name ;)
           // You need to program your own letters :)
     }
}

If this does not help sorry. But I would do it like this as this is easy to implement and to use.

Leave a Comment