Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Void Type not allowed Error in Sys out statement  RSS feed

 
JavaL Learner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have come across this problem where I get the below error in my class Invoker.java (The error is on the highlighted + operator)

Invoker.java:9: error: 'void' type not allowed here
System.out.println("To eat " + (f.getClass().getName()) + " you have to " + f.eat());

If I change the sys out statement to

System.out.println("To eat " + f.getClass().getName());

This works fine.

I was referring to this thread http://www.coderanch.com/t/411950/java/java/Error-void-type-allowed which says that f.getClass().getName() should return a string, which as per the Java 7 api does.

What am I missing here?

Thanks for your help !!
 
JavaL Learner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ignore this message. The error shown was on the wrong + operator. The problem was with the f.eat() method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!