Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > help with extends

Reply
Thread Tools

help with extends

 
 
John Smith
Guest
Posts: n/a
 
      08-31-2008
class above {

void display() {

class family {

-- some functions --

}

class creature extends family {

public void creature() {
} // default constructor

public void creatureObj(obj y) {

-- some functions --

} // creatureObj's constructor

public String getName() {
return realName;
} // Accessor for realName

public String getColour() {
return realColour;
} // Accessor for realColour

public int getLegNumber() {
return legNumber;
} // Accessor for legNumber

public int getEyeNumber() {
return eyeNumber;
} // Accessor for eyeNumber


} // end class creature


creature inputCreature = new creature();


System.out.println("Name is " + inputCreature.getName());
System.out.println("Colour is " + inputCreature.getColour());
System.out.println("Leg Number is " + inputCreature.getLegNumber());
System.out.println("Eye Number is " + inputCreature.getEyeNumber());


} // display
} // above



I know I'm actually calling the default constructor which returns
everything as null in the output such as for inputCreature.getName(). So
the code above is wrong.

How should I code it such that it calls the corresponding value for
inputCreature.getName() ?
 
Reply With Quote
 
 
 
 
John Smith
Guest
Posts: n/a
 
      08-31-2008
John Smith wrote:
> public void creatureObj(obj y) {
>
> -- some functions --
>
> } // creatureObj's constructor


oops, should be creature instead of creatureObj..

-js
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
extends multiple classes? Ian Stanley Java 13 03-13-2012 03:38 PM
compile javac help needed for beginner. apparently it doesnot understand the word extends????? George Kooper Java 3 01-20-2004 03:01 PM
Samba 3 extends lead over Win 2003....newbie or wannabe mcse's - get a clue! DaveT MCSE 8 11-05-2003 08:54 PM
[BEANSHELL] Extends SOl Java 0 07-19-2003 06:12 PM
Re: Properties2 extends Hashmap, pros and cons? Jon Skeet Java 5 07-08-2003 06:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57