final Class
A final
class is a class that can’t be used as a base class. To declare a class as final
, just add the final
keyword to the class declaration:
public final class BaseBall
{
// members for the BaseBall class go here
}
Then no one can use the BaseBall
class as the base class for another class.
When you declare a class final, all its methods are considered final
as well. The final
keyword isn’t required on any method of a final
class.