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.


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

Results 1 to 3 of 3

Thread: @override

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Thanked 0 Times in 0 Posts

    Default @override

    What does @override mean in java? I'm a noobie.

  2. #2
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    San Pedro Sula, Honduras
    My Mood
    Thanked 1 Time in 1 Post

    Default Re: @override

    I saw that this week.

    Alright. Remeber Java is obect-oriented?
    So classes are some sort of "objects" that have methods and attributes (variables) you think they need, say your class boats needs to have a name, so you declare a variable for name called NameOfBoat.

    Some objects are just one entire category of other objects. If you think about a boat, there are several types of boats: fishing boats, carrier boats, battleships. So the class or object "boat" is the most basic, the blueprint for all the type of boats. In java you can have another class (child) like carrier boat inherit the attribues and methods from its parent (class "boat"), through a declaration called extends followed by the parent class.

    This enables you to use the methods and attributes of the parent class, without writting code for it.

    You might want to review other terms related to inheritance like "super()" or "this." or "super." and "protected".

    So sometimes the parent's got a method which is no longer good for the child. What you'd like to achieve with that method is entirely different. so what you do is that you type in @override and below that you declare the method thats on the parent that you'd like to change.

    I tried to make it short. I hope this gives you an idea.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: @override

    It might be helpful to read this lesson on annotations. The 4th page in that trail discusses the @Override annotation which says:

    "@Override informs the compiler that the element is meant to override an element declared in a superclass. While it is not required to use this annotation when overriding a method, it helps to prevent errors. If a method marked with @Override fails to correctly override a method in one of its superclasses, the compiler generates an error."

    Some IDEs check annotations before compile time and will let you know if the annotation is appropriate, so they can be used as a pre-check of the code's syntax.

Similar Threads

  1. problem with @Override in onDraw
    By spock42 in forum Android Development
    Replies: 1
    Last Post: March 5th, 2013, 10:13 AM
  2. Replies: 0
    Last Post: July 19th, 2012, 09:02 AM
  3. Classpath override not working correctly in command prompt?
    By MeteoricDragon in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 20th, 2011, 12:05 PM
  4. override list add method?
    By ober0330 in forum Collections and Generics
    Replies: 10
    Last Post: July 17th, 2011, 07:34 PM
  5. Override class method
    By mekie in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 31st, 2010, 07:06 PM

Tags for this Thread