How can I align it properly?
got hard time. sorry i'm just new in Java

public class MultiplicationTable {
    public static void main(String[] args) {
       
        int[][] multtable = new int[11][11];


        System.out.print("*");
        for (int a=1;a<=10;a++)
        {
            System.out.print("\t"+a) ;
        }
        System.out.println(" ");
        for(int i=0; i<=10; i++) {           // this loop is for rows
            for(int j=0; j<=10; j++) {       // this loop is for columns
                multtable[i][j] = i*j;
            }
        }
        System.out.print("\t");
        System.out.print("------------------------------------------------------------------");
        System.out.println("");

        for(int i=1; i<11; i++) {
            System.out.print(i+"|\t");

            for(int j=1; j<11; j++) {
                // this ensures that all single-digit numbers will line up into columns
                System.out.print(multtable[i][j]+"\t");
            }
            // make a new line for every row
           System.out.print("\n");
        }
    }
}

See the "printf" method of PrintWriter, or the format method of String in the API docs, then simply format the print so each number (with leading/separating/trailing whitespace) uses the same number of characters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.