What does @Override mean?

public class NaiveAlien extends Alien

    public void harvest(){}


I was trying to understand my friend's code, and I do not get the syntax, @Override in the code. What does that do and why do we need in coding? Thanks.


It's a hint for the compiler to let it know that you're overriding the method of a parent class (or interface in Java 6).

If the compiler detects that there IS no function to override, it will warn you (or error).

This is extremely useful to quickly identify typos or API changes. Say you're trying to override your parent class' method harvest() but spell it harvset(), your program will silently call the base class, and without @Override, you wouldn't have any warning about that.

Likewise, if you're using a library, and in version 2 of the library, harvest() has been modified to take an integer parameter, you would no longer override it. Again, @Override would quickly tell you.

Need Your Help

How to create a login like below in android?

android design user-interface login flat

I need to create a login page like below in android? how can i achieve that?

unable to merge entity with derived entities

hibernate java-ee jpa jpa-2.0 java-ee-6

i am trying out derived entities using @JoinedColumns,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.