What does @override mean in java? I'm a noobie.
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.
What does @override mean in java? I'm a noobie.
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.
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.