wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg. final keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Reg. final keyword" Watch "Reg. final keyword" New topic
Author

Reg. final keyword

Angela Narain
Ranch Hand

Joined: Apr 14, 2001
Posts: 327
Consider the below code :

I suppose we can always instantiate a final class.
Declaring the class as final just means that it cannot
be subclassed. Am i right ?

I just tried the same with Math class as below :

which gives compiler error

Math() has private access in java.lang.Math

Is it solely for the reason that we invoke the static methods of Math class using the class name..
Marcelo Sousa
Greenhorn

Joined: Sep 21, 2001
Posts: 2
The Math Class is actually final, but remember it�s constructor is private! So, you can�t instantiate this class.

Tchau
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reg. final keyword
 
Similar Threads
about Math class
Inner Class in the Interface
Extending a class with private constructor
Private Final Method
class Math is concrete class but still it cannot be instantiated.