@Override annotation was added in JDK 1.5 and it is used to instruct compiler that method annotated with @Override
is an overridden method from super classor interface. Though it may look trivial @Override is particularly useful while
overriding methods which accept Object as parameter just like equals, compareToor compare() method of Comparator
interface. @Override is one of the three built in annotation provided by Java 1.5, other two are @SuppressWarnings and @Deprecated. Out of these three @Override is most used because of its general nature, while @SuppressWarnings is also used while using Generics, @Deprecated is mostly for API and library. If you have read my article common errors while overriding equals method than you have see that one of the mistake Java programmer makes it, write equals method with non object argument type as shown in below example:
0 komentar:
Posting Komentar