I recently learned that use of System.out.print(); results in this error:
The method print(boolean) in the type PrintStream is not applicable for the arguments ()
I found this when helping somebody else with their coding. Of course the natural question is: why do they have that in their code with no arguments. I did not find any mention of the error for this case in documentation.
Searching the documentation I found that System.out.print(T t) is defined for many types, but when no argument at all is present, it defaults to print(boolean x). Reference.
Then, of course it complains that the argument is not applicable.
The person I was helping is a new student who had frequently used System.out.println() and was baffled as to why this error was occurring.
The student eventually wanted a string there and the method was just a placeholder. I explained an argument of some sort is required for compilation.
My question is: Why does the compiler make this assumption and thus give this error?
I think the console cut off the whole message, when I try to compile System.out.print() in Intellij it shows all messages:
The compiler tries to match all methods from the order in which they happen to be declared in the file.