This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes final methods Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "final methods" Watch "final methods" New topic
Author

final methods

Gautam Sewani
Ranch Hand

Joined: Apr 19, 2002
Posts: 93
class A{
final static void AMethod() {}//final static method
}
abstract class An extends A {
public static void AMethod() {}
/*
static method is not overriden,it is hidden
*/
}
Then why does this code not compile?
Someone from this forum only said that static method are not overriden,they are just hidden.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
You're right, static methods are not overridden, they are hidden. But, from the JLS, §8.4.3.3 final Methods:

A method can be declared final to prevent subclasses from overriding or hiding it. It is a compile-time error to attempt to override or hide a final method.

Don't forget the second part of that statament.
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: final methods
 
Similar Threads
Question in RHE CD
Can static method be overriden by a static method?
difference between static and final method
Are static methods are overriden??
Static method is implicitly final?