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:
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 codeTo 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:
No comments :
Post a Comment