Search code examples
javaprintingrowtabular

print different methods in row java


It is possible to print 3 different functions horizontally instead of vertically?

1st function

  1. List item
  2. List item
  3. List item
  4. List item

2nd function

  1. List item
  2. List item
  3. List item

3nd function

  1. List item
  2. List item
  3. List item

So instead of printing it vertically, it would print it horizontally in a table. (like three different rows)

This is my function. And I want to print 3 of them in row.

      public static void print_alpha() {
          for (int k = 1; k < alpha.size(); k++ ) {
          for (int i = 2*k - 1; i > 0 ; i-- ) {
          System.out.printf("#");}
          System.out.println("");  

          }
          System.out.printf("-----");
        System.out.println("");
        System.out.println("");
      }

Solution

  • Use System.out.print (or printf) instead of println. See http://docs.oracle.com/javase/6/docs/api/java/io/PrintStream.html#println(java.lang.String) to understand what println does.