Trying to print integers and text using prinf in java

You’re completely missing the point of String.format. The point of it is to avoid manually formatting and concatenating strings representing elements, which you are doing anyway.

Since if (num1 == 24 && num2 == 00) must be true to be in that if block you can simply System.out.println("24 00 Midnight");.

Leave a Comment