• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg. final keyword

 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Math Class is actually final, but remember it�s constructor is private! So, you can�t instantiate this class.

Tchau
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic