Monday, December 14, 2015

[Java][Resolved] void type not allowed here


Method showColor() in class A with return type void return nothing.
Invoking this method within System.out.println statement which return nothing would cause a RuntimeException, since it's don't know what should it print at Runtime environment:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code 
To resolve it , method 1 is set an return type to the method you used in System.out.println(), for example:
or you can move the method with void return type out from System.out.println() statement:

Reference:


No comments :

Post a Comment