Results 1 to 4 of 4
  1. #1
    razorfever is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default 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.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,335
    Blog Entries
    7
    Rep Power
    20

    Default 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,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    razorfever is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default Re: Using an array which is in a superclass

    The array is private and I do have getter/setter methods.

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

Similar Threads

  1. Superclass Question
    By Dark in forum New To Java
    Replies: 15
    Last Post: 04-12-2011, 11:40 AM
  2. Class and SuperClass
    By pompeez in forum New To Java
    Replies: 2
    Last Post: 08-05-2009, 10:55 AM
  3. SuperClass of an Object
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-06-2007, 02:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •