Results 1 to 3 of 3
  1. #1
    AndrewM16921 is offline Senior Member
    Join Date
    Jan 2009
    Location
    NJ, USA
    Posts
    261
    Rep Power
    6

    Default Overriding Methods

    Okay, I have a superclass called "Piece" and the subclass, "Wall", which extends it. In the superclass I have a method called act(), but when it is a Wall I want it to override that method and use Wall's act(). Normally this would work, as far as I know, but for some reason it isn't. Does it matter that my array Piece[][] field contains Wall objects? So, if I say field[i][j].act() on a Wall object in that array (of type Piece), should it use Wall's act() or Piece's act()?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    AndrewM16921 is offline Senior Member
    Join Date
    Jan 2009
    Location
    NJ, USA
    Posts
    261
    Rep Power
    6

    Default

    EDIT: I think I know the problem.
    Last edited by AndrewM16921; 09-23-2009 at 07:01 AM.

Similar Threads

  1. Method Overriding - Seriously confused :-(
    By fullmetaljacket in forum New To Java
    Replies: 4
    Last Post: 05-26-2009, 04:18 PM
  2. [SOLVED] Method Overriding
    By MithunDhar in forum New To Java
    Replies: 3
    Last Post: 04-06-2009, 08:02 AM
  3. Replies: 1
    Last Post: 04-01-2009, 02:00 AM
  4. Replies: 3
    Last Post: 04-08-2008, 07:12 AM
  5. is overriding static method possible
    By raghu in forum Advanced Java
    Replies: 1
    Last Post: 01-22-2008, 12:38 AM

Posting Permissions

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