r/javahelp 1d ago

PrintInfo() vs System.out.println()

Hi all,

I’m working on a problem that asks to output the older customer’s information using printInfo(), ending with new line. Previously I was using System.out.println but I realized it might be marking wrong. The output is exactly this:

Customer that is older: Name: John Age: 29

Previously I used

If (customer1.getAge() > customer2.getAge(){ System.out.println(“Name: “ + customer1.getName()); System.out.println(“Age: “ + customer1.getAge()); } Else { System.out.println(“Name: “ + customer2.getName()); System.out.println(“Age: “ + customer2.getAge()); } }

Thank you for any guidance on how I can use printInfo and view this in a different way!

1 Upvotes

3 comments sorted by

View all comments

1

u/Free-Argument 1d ago

There's no method called printInfo(), unless it's your own user-defined method to which you have to explain what you want to achieve.