File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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: 1950

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.

It is sorta covered in the JavaRanch Style Guide.
subject: Compile time erroe in the code.
It's not a secret anymore!