Results 1 to 4 of 4
  1. #1
    awebbtt is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default Some advice please!

    Is it possible to call a method within a child class from within the parent class?

    If it is how do I do it; if not what is an alternative?

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

    Default

    To me that would smell of a very broken design. I'd rethink the overall design of your program so that you don't require this.

    Either that or give us an explanation why you think you need this and perhaps we can help you find alternatives.

  3. #3
    awebbtt is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default

    Actually, I just started using java and I am only now learning about design structure and inheritance, etc., so I wanted to know if it was possible/practical.

    After posting here I did some looking on the web and I realized that it isn't done, so I made the method call from main instead.

    Any advice is welcome.

    Thanks for the reply.

  4. #4
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    The idea is, given that the object is of type SuperClass, how are we supposed to know if it is SubClassA, SubClassB, or so forth? We don't, so we can't.

    Unless we typecast, which we don't want to do in OOP.

Similar Threads

  1. Need advice on JSP with bean
    By butterhero in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-18-2009, 12:40 PM
  2. Advice needed
    By dineshjf in forum Advanced Java
    Replies: 18
    Last Post: 01-09-2009, 04:17 AM
  3. Replies: 2
    Last Post: 12-19-2008, 04:03 PM
  4. New Database Approach Advice
    By greenco in forum New To Java
    Replies: 2
    Last Post: 12-02-2008, 09:26 AM
  5. Advice on best method for....
    By shaungoater in forum Java 2D
    Replies: 1
    Last Post: 06-23-2008, 08:36 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
  •