@override?

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

[294 byte] By [George4a] at [2007-11-27 11:42:12]
# 1

@override is meta-data and should be in a javadoc /** comment field

It is used to indicate what class the overridden method is overridden from.

tjacobs01a at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 2

I thik it was introduced in java 5 and is an annotation type.

Try looking here:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Override.html

c0demonk3ya at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 3

Upgrade.

BigDaddyLoveHandlesa at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 4

> @override is meta-data and should be in a javadoc /**

> comment field

>

Wrong. Annotations aren't Javadoc entries.

> It is used to indicate what class the overridden

> method is overridden from.

Wrong. It only indicates THAT it's overridden, not what it's overridden from.

jwentinga at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 5

Could you provide more information please? Upgrade for what?

regards,

George

George4a at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 6

Thanks jwenting!

> > It is used to indicate what class the overridden

> > method is overridden from.

>

> Wrong. It only indicates THAT it's overridden, not

> what it's overridden from.

Could you show me a sample please? From java.sun.com, I can not find a sample.

regards,

George

George4a at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 7

Thanks c0demonk3y,

> I thik it was introduced in java 5 and is an

> annotation type.

>

> Try looking here:

>

> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Over

> ride.html

Could you show me a sample please? I have read the page you referred, but I can not use it without looking at a sample. :-)

regards,

George

George4a at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 8

> Could you provide more information please? Upgrade

> for what?

>

>

> regards,

> George

See reply #2. Upgrade to at least Java 5. (JDK 1.5)

Kaj

kajbja at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 9

> Thanks c0demonk3y,

>

> > I thik it was introduced in java 5 and is an

> > annotation type.

> >

> > Try looking here:

> >

> >

> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Over

>

> > ride.html

>

> Could you show me a sample please? I have read the

> page you referred, but I can not use it without

> looking at a sample. :-)

>

>

> regards,

> George

public class BaseClass {

public void sayHello() {

System.out.println("Hello there!");

}

}

public class ExampleClass extends BaseClass {

@Override

public void sayHello() {

System.out.println("Hi there!");

}

}

Kaj

kajbja at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...
# 10

@Override is an example of an annotation, which is a syntactic feature introduced at Java 1.5. It's not part of the language at 1.4. Therefore you have two choices - comment them out or move to a more recent java environment.

But note a program which has been writtern for 1.5 or 1.6 may well be using other features of it, like enumerated values and generics. So you may get arround the @Override problem and then find you have other, less tractable incompatibility.

@Override is pretty simple, by the way, by annotating a method you are indicating your intent that this method should override a method in a superclass. This gives you a compile time error should you make the all to easy mistake of getting the signature of an overriding method slightly wrong and, as a result, not succeeding in the override and finding that the superclass version is the one that gets called.

malcolmmca at 2007-7-29 17:42:48 > top of Java-index,Java Essentials,Java Programming...