Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Condensing multiple System.out.prinln() into one [closed] without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
I have
for( int x = 0; x < rp.studentRecords.length; x++){ System.out.println("Student name: " +rp.studentRecords[x].getName()); System.out.println("Major: "+ rp.studentRecords[x].getClass().getName()); System.out.println("Age: "+ rp.studentRecords[x].getName()); System.out.println("Year " +rp.studentRecords[x].getYear()); System.out.println("Credits Earned: "+ rp.studentRecords[x].getCredits()); System.out.println("Remaining Credits: "+ rp.studentRecords[x].getRemainingCredits()); System.out.println("-------"); }
and I need to condense those System.out.println()s into a single one.
Answer
What you could try is to use String.format
like
String output = String.format ("Name: %snMajor: %snAge: %s", rp.studentRecords[x].getName(), rp.studentRecords[x].getClass().getName(), rp.studentRecords[x].getAge()); // then print it out System.out.println (output);
We are here to answer your question about Condensing multiple System.out.prinln() into one [closed] - If you find the proper solution, please don't forgot to share this with your team members.