wood burning stoves 2.0*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile time erroe in the code." Watch "Compile time erroe in the code." New topic
Author

Compile time erroe in the code.

Phillipe Rodrigues
Ranch Hand

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





Output:
---------- Compile ----------
Sub_class.java:8: 'void' type not allowed here
System.out.println(Sub_class.return_Number());
^
Sub_class.java:9: 'void' type not allowed here
System.out.println(Super_class.return_Number());
^
2 errors
Normal Termination
Output completed (0 sec consumed).


Thanks,
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1761
    
    7

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.


-kolli
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compile time erroe in the code.