java - What does @Override mean? -


public class naivealien extends alien {      @override     public void harvest(){}  } 

i trying understand friend's code, , not syntax, @override in code. , why need in coding? thanks.

it's hint compiler let know you're overriding method of parent class (or interface in java 6).

if compiler detects there no function override, warn (or error).

this extremely useful identify typos or api changes. you're trying override parent class' method harvest() spell harvset(), program silently call base class, , without @override, wouldn't have warning that.

likewise, if you're using library, , in version 2 of library, harvest() has been modified take integer parameter, no longer override it. again, @override tell you.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -