@override?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   George3_George3
Posted On:   Wednesday, July 25, 2007 10:45 AM

			
Hello everyone,


I am using JDK 1.4 and there is a compiling a 3rd party
program error because of un-recognized word @override.
Could anyone let me know what is the function of @override
and in order to use it, which version of JDK is required?


thanks in advance,
George

Re: @override?

Posted By:   WarnerJan_Veldhuis  
Posted On:   Wednesday, July 25, 2007 12:47 PM

It's a Java 5 feature called annotations. This annotation in particular is used to indicate that this method overrides the one from the superclass. Any typos, wrong arguments are caught at compile time. A very handy feature which I use a lot.



Example:

public int hashcode() {...} //this will compile



@Override

public int hashcode() {...}



This last one will not compile because the compiler will see if the method matches the super method. hashcode() does not exist in the super class and the compiler will complain, because the correct name is hashCode (capital C) and not hashcode()
About | Sitemap | Contact