Results 1 to 4 of 4
- 10-29-2011, 02:40 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 2
- Rep Power
- 0
Using an array which is in a superclass
Ok so I have these two classes: Book and Encyclopedia. I want to create a method in Encyclopedia. I want it to modify an array which is an object in Book class. I'm not allowed to take the array as a method input like this: public void MethodName(Book [] a, String ...){ Instead, I have to find a way to call that array in the method and modify one of the elements in it. I know how to modify the element, just I don't know how to call the array in a superclass to a subclass. Thanks.
- 10-29-2011, 03:57 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,422
- Blog Entries
- 7
- Rep Power
- 17
Re: Using an array which is in a superclass
If that array isn't private there is no problem at all, you can do with it whatever you want. If it is private and there is no method in that superclass that hands over that array, you have no way to access that array. I don't understand your last remark.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-29-2011, 06:28 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 2
- Rep Power
- 0
Re: Using an array which is in a superclass
The array is private and I do have getter/setter methods.
- 10-29-2011, 07:05 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Similar Threads
-
Superclass Question
By Dark in forum New To JavaReplies: 15Last Post: 04-12-2011, 11:40 AM -
Class and SuperClass
By pompeez in forum New To JavaReplies: 2Last Post: 08-05-2009, 10:55 AM -
SuperClass of an Object
By Java Tip in forum Java TipReplies: 0Last Post: 12-06-2007, 02:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks