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 Inheritance pbs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inheritance pbs" Watch "Inheritance pbs" New topic

Inheritance pbs

prerna boja
Ranch Hand

Joined: Aug 19, 2004
Posts: 67
Hi all,

package Food;

public class Zoo {

public void coolMethod()



package Food;
import Food.Zoo;

public class Moo extends Zoo{

public static void main(String[] args) {
Zoo z= new Zoo();

System.out.println("A Zoo Says, " +z.coolMethod());---------- //1



I am getting an error saying "Void" type not allowed here on line 1.

can anybody tell what wrong I have done.
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
First, use code tags when you post code. (look below next to all the little faces as your posting)

In your code the method 'coolMethod()' has a return value of void, it doesn't return anything, so it can't be concatinated to the string on line 1.

I think what you want to do is return "Hello" rather than System.out.println("Hello")
Don't get me started about those stupid light bulbs.
subject: Inheritance pbs