Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Arnold Scott   on Dec 02 In Java Category.

  
Question Answered By: Dale Jones   on Dec 02

See this sample  code--

Class A{
private A(){

}

public static A CreateObject(){
return new A();
}
}

Class B{
public static void main(String arg[]){
A a=A.CreateObject();
}
}

Hope u would get it. Well why do u need this actully this is used for
singletone pater n the code whc i hav given here is not exactly
singleton of pattern. (I can do tht also).

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on how can i access a private contructor. Or get search suggestion and latest updates.


Tagged: