| Author |
Overriding
|
archu sweet
Ranch Hand
Joined: Mar 07, 2011
Posts: 66
|
|
I just wanted to know what is wrong in the above code ?
|
 |
archu sweet
Ranch Hand
Joined: Mar 07, 2011
Posts: 66
|
|
|
It is throwing this error : Exception in thread "main" java.lang.Error: Unresolved compilation problem
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12956
|
|
An error like "unresolved compilation problem" probably means that you have some old *.class files somewhere and that the compiler gets confused. Delete all your *.class files and re-compile everything again.
What is wrong: Look at lines 2 and 5. What do you think could be wrong there?
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
archu sweet
Ranch Hand
Joined: Mar 07, 2011
Posts: 66
|
|
|
i think overriding of same functions is not possible in same class....am i correct??
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
Yes. Overriding can only be done by subclasses.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
mallikarjun dontamsetti
Ranch Hand
Joined: Mar 18, 2011
Posts: 236
|
|
|
You are doing overloading not overriding.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
mallikarjun don wrote:You are doing overloading not overriding.
He is doing neither.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12956
|
|
|
You have two doit() methods - the same name, the same arguments. When you call doit() (without arguments) on an A object, how is Java supposed to know which of the two to call?
|
 |
Yunnan Zhou
Ranch Hand
Joined: May 04, 2011
Posts: 31
|
|
oh,my god.you define tow same methos in the same class.
if you want override a method.you first have to inherit another class.
|
I'am a Chinese.I like Java.Hello.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32836
|
|
Welcome to the Ranch
|
 |
Yunnan Zhou
Ranch Hand
Joined: May 04, 2011
Posts: 31
|
|
to Campbell Ritchie
thank you so much. nice to meet you.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32836
|
|
You're welcome
|
 |
 |
|
|
subject: Overriding
|
|
|