Selva Kumar N

Greenhorn
+ Follow
since Aug 22, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Selva Kumar N

Hi Rajesh Vass,

why do we create private constructors in java classes?

It is because to restrict instantiate the class(i.e the class with private constructor will not allow to create instance of that class by any other classes)

And for creating that class object we give static factory methods. Instead why cant we dont we use public for constructor?

The Constructor of this class is private so a public static method of this class is used to get the Object of the class. Because no other class can't instantiate this calss. This patter is called as Singleton pattern

for more info refer: http://www.roseindia.net/javatutorials/J2EE_singleton_pattern.shtml

Cheers!

Selva


12 years ago