What you could try is to use String.format
like
String output = String.format ("Name: %s\nMajor: %s\nAge: %s",
rp.studentRecords[x].getName(),
rp.studentRecords[x].getClass().getName(),
rp.studentRecords[x].getAge());
// then print it out
System.out.println (output);
solved Condensing multiple System.out.prinln() into one [closed]