0

As per my understanding, a class is declared as final to prevent it from being extended/inherited. So I see there can be security and probably some performance gains in this regard.

But is there a very specific design decision behind this? Say for eg: to realize some kind of design pattern? I did go around a similar thread here! but the answer was not really what I was looking for

Community
  • 1
  • 1
  • Still the linked question discusses the problem quite well. See also [my comment](http://stackoverflow.com/questions/30258274/why-system-class-declared-as-final-and-with-private-constructor#comment48616517_30258274) there. Actually I don't see what could be added, thus I'd vote to close this as duplicate. – Tagir Valeev Sep 30 '15 at 07:19
  • I don't know why the answer doesn't fit your expectations but this is the only valid answer I know related to your question. – Fabien Thouraud Sep 30 '15 at 07:21

1 Answers1

1

Singleton Pattern:

-Private Constructor

-Only static methods

-No need to have more than one object of this class or an object at all

-No need to extend this fundamental class

Ilja KO
  • 1,272
  • 12
  • 26
  • That's not a Singleton pattern. `Runtime.getRuntime()` is a singleton, but `System` is utility class. – Tagir Valeev Sep 30 '15 at 07:37
  • than for arguments sake lets call it the Java System Class Pattern....Singleton is the closest PAttern. The Class itself is instantiated/loaded by the JVM to use the static fields and functions – Ilja KO Sep 30 '15 at 07:46
  • it is not singleton pattern because in singleton pattern the object is not final – hossein ketabi Jan 09 '16 at 21:29
  • what? The class itself is final and why shouldnt the object of a Singleton not be final also? You just need one of them and you dont instantiate it more than once while code is running... – Ilja KO Jan 12 '16 at 18:02