Condensing multiple System.out.prinln() into one [closed] Code Answer

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.

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());

and I need to condense those System.out.println()s into a single one.


What you could try is to use String.format like

String output = String.format ("Name: %snMajor: %snAge: %s", 

// 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.

Related Posts

Tutorial Guruji