| Author |
Interface - AbstractClass Collision
|
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
Why am i getting error in above code? Please if somebody can explain underlying reason for it?
|
Regards
Azrael Noor
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8438
|
|
|
Because abstract and private are like oil and water. They do not mix
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Maneesh is right. Abstract means the method is meant to be overridden, but private methods cannot be overridden (only shadowed).
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
Thank You for reply
but what about following case as there is default in class and public in interfaces and it is working fine why so? as methods are abstract both sides?
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3793
|
|
|
If a method is overridable at all, you can always override it with fewer restrictions. So overriding package or protected methods with public is fine.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12926
|
|
The error that you are getting looks really strange.
It indicates that the class file is invalid. Somehow the compiler that you are using has accepted illegal code (a method that is both abstract and private) without giving an error message, and produced an invalid class file. That's a bug in the compiler.
Which compiler are you using? Is this the standard javac from the JDK (if so, what version)?
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
Thank you for providing information
I am Using JDK version 6, JAVAC
what other compilers are available which compile Java Code?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
Where did you get that compiler from?
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
|
From Oracle Website
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
I am very surprised it would allow those two modifiers together. Maybe the class was compiled with a different compiler, or (even) it has been altered after compilation. Or there was an error in transmission or recording of the .class file.
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
BUG IN JAVA BUG IN JAVA
but i need to continue the program
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
Azrael Noor wrote:BUG IN JAVA BUG IN JAVA
I suggest you try compiling that class again, with the same version of the compiler, before you try to report a bug
|
 |
 |
|
|
subject: Interface - AbstractClass Collision
|
|
|