How to print the value of variable in java [duplicate]

If System.out.printf is giving you this error:

 The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int)

Then you must configure your project for the proper Java version.

Methods with variable arguments were introduced with Java 5.

Alternatively, you could do:

System.out.printf("The Sum of %d and %d is %d\n", new Object[] {a, b, sum});

Leave a Comment