GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Notizen

Ohne Titel

vivek singh Englisch 4 Seiten

Inhalt der Notizen (4)

Seite 1

Singleton class:

1. One Object

2. Return the same object whenever we create a new instance

We use Singleton class to prevent the creation of multiple classes.

Seite 2

Eagle initialization: instance created at the starting of the server in web application.

Lazy initialization: instance created during first user call.

Seite 3

Factory method: it's like a class calling constructor similarliy singleton class calls factory initialization.

Returns the object of the class.

Example :

1. Runtime run = Runtime.getRuntime();

2. Calender c1 = Calender.getinstance();

Here new operator is not used to create object. But we call static method: getRuntime() and getInstance(). this return object of this classes.

Seite 4

Steps to Create Singleton Class:

1. create a static variable object of type class.

2. private constructor_name(){}

3. Creating a public method known as getInstance( ) in which we will create a instance and return the object

Informationen

Beschreibung
Notiz am Ohne Titel, erstellt von vivek singh am 04/06/2019.
Erstellt von
vivek singh
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck