I tried to call a method in printlnfrom a super class using the object that I have created for the super class. I got this error
"operator + cannot be applied to java.lang.string void"
System.out.println("Contents of objsuper: " + objsuper.showij());
Replace the following line
System.out.println("Contents of objsuper: " + objsuper.showij());
with
System.out.println("Contents of objsuper: ");
objsuper.showij();
The reason for this is, the return type of objsuper.showij() is void and therefore, operator + cannot be applied to it. A void method is like doing something but not returning a value and since there is no value returned by it, you can not append it to anything using + operator; you need to call it separately the way I have done above.
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