Hi guys I have a bit of a problem here about the alignment
no what I try it always end up like that, the 2nd-3rd row course and sexcode column is what I want to fix >.<

package studlist;

here's my code:

public class StudList {

    public static void main(String[] args) {
        //Variable Declaration

        int totalRec = 0, totalF = 0, totalM = 0, ctr;

    String[] studNo = {"397-1010", "380-1120", "390-1350", "345-1235"};
    String[] studNa = {"R.Santos", "A.Cruz", "J.Lim", "S.Corona"};
    String[] course = {"BSIT", "BSCS", "BSIT", "ACT"};
    char[] sexCode = {'M', 'M', 'F', 'F'};

    //Print Titles & Subtitles

    System.out.println("           List of Students");
    System.out.println();
    System.out.print("Student No.\tName\t\tCourse\t\tSex \n");

    //Print Student Records

    for (ctr = 0; ctr < studNo.length; ctr++)
    {
        System.out.print(studNo[ctr] + "\t");
        System.out.print(studNa[ctr] + "\t");
        System.out.print(course[ctr] + "\t\t");
        System.out.print(sexCode[ctr] + "\n");
    }


    }
}

:D hehe nvermind.. I already found a way

There's something to be said for...

System.out.println("Student No.  Name        Course  Sex");
...
   System.out.printf("%-11s  %-10s  %-6s  %1s\n", studNo[ctr], studNa[ctr], course[ctr], sexCode[ctr]);
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.