Hi All,
Here is my programme.
<code>
class Parent {
public int doStuff(float y) {
return 4;
}
}
public class OverridingTest extends Parent {
public Integer doStuff(float y) {
return 2;
}
public static void main(
String[] args) {
}
}
</code>
After compiling this I am getting the following error.
OverridingTest.java:8: doStuff(float) in OverridingTest cannot override doStuff(
float) in Parent; attempting to use incompatible return type
found : java.lang.Integer
required: int
public Integer doStuff(float y) {
^
1 error
My doubt is, when the return type is Integer I should be able to return int primitive, I mean, auto boxing should work here. Why this code is not getting compiled?
Thanks & Regards,
Surya.
[ November 12, 2006: Message edited by: Sai Surya ]
Sai Surya, SCJP 5.0, SCWCD 5.0, IBM 833 834
http://sai-surya-talk.blogspot.com, I believe in Murphy's law.