When I write:
System.out.println("Give grade: ", args[0]);
It gives the error:
The method println(String) in the type PrintStream is not applicable for the arguments (String, String).
Why is this so? However, when I try to write
System.out.println("Give grade :");
System.out.println(args[0]);
No error shows. Is there a way I can write the above in one line of println()?
The two that work only take one parameter, the one that fails takes two. Any chance you have a Javascript or Python background? Java enforces parameter type and count (like C).
Try
System.out.println("Give grade: " + args[0]);
or
System.out.printf("Give grade: %s%n", args[0]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With