wood burning stoves
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
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 ----------
Sub_class.java:8: 'void' type not allowed here
Sub_class.java:9: 'void' type not allowed here
2 errors
Normal Termination
Output completed (0 sec consumed).

Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

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: http://aspose.com/file-tools
subject: Compile time erroe in the code.
It's not a secret anymore!