File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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: 1752
    
    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
 
wood burning stoves
 
subject: Compile time erroe in the code.
 
Similar Threads
overriding of static method
static and abstract methods
static member
Void not allowed here error
static method not running