This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Compile time erroe in the code. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile time erroe in the code." Watch "Compile time erroe in the code." New topic

Compile time erroe in the code.

Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
Why is compile output i get as below?

---------- Compile ---------- 'void' type not allowed here
^ 'void' type not allowed here
2 errors
Normal Termination
Output completed (0 sec consumed).

Jelle Klap

Joined: Mar 10, 2008
Posts: 1914

You're calling PrintStream's println() method and passing in the return value of the return_Number() method. However, the return type of the return_Number() method is void, which is why it's not valid to pass the result of this method as an argument to the println() method - the return_Number() method doesn't yield a return value.
[ October 07, 2008: Message edited by: Jelle Klap ]

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Ravikanth kolli
Ranch Hand

Joined: Feb 10, 2008
Posts: 179

The return type of both the methods that are called in the println statement are void, So it doesnot return anything and thus the error.

I agree. Here's the link:
subject: Compile time erroe in the code.
It's not a secret anymore!