Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Overriding a method, semi complicatedly.

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Overriding a method, semi complicatedly.

    So I have an sub-interface that extends a super-interface. In this sub-interface it is required of my assignment to over-ride a method that was given in the super-interface. Now when I implement the sub-interface in a class, the class in eclipse is requiring both methods from the sub and super interface to be in the class. But they are also the same name, "duplicate method" error. So I can't change the name of the super-interface one(which is the one i'd like to as I have overridden it) or comment it out because then it won't be in the class.

    When I over-ride in the sub interface I give the method the exact same name and parameters, I just add a custom exception " throws mycustomexception"

    Suggestions?

    *Fixed* - Missing @Override before the overriding method.
    Last edited by Tron22; October 28th, 2012 at 04:14 PM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Overriding a method, semi complicatedly.

    Quote Originally Posted by Tron22 View Post
    *Fixed* - Missing @Override before the overriding method.
    That annotation doesn't actually *do* anything other than make sure that a method is overriding another one. I would bet that you changed something else in the process of adding @Override that actually fixed your problem.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Overriding Object's toString() method outside of their class
    By aussiemcgr in forum Java Theory & Questions
    Replies: 11
    Last Post: May 13th, 2012, 02:32 AM
  2. Advantages of method Overloading and Overriding
    By tcstcs in forum Java Theory & Questions
    Replies: 2
    Last Post: January 19th, 2012, 04:55 AM
  3. Overriding Superclass Static Methods, Using the Superclass Method
    By snowguy13 in forum Java Theory & Questions
    Replies: 10
    Last Post: December 21st, 2011, 08:30 AM
  4. Help with overriding
    By JavaStudent1988 in forum Java Theory & Questions
    Replies: 2
    Last Post: October 18th, 2011, 01:08 AM
  5. Overloading vs Overriding
    By nickypass in forum Java Theory & Questions
    Replies: 1
    Last Post: October 17th, 2010, 01:53 AM