RITENDRA
Answered On : Nov 1st, 2012
getInstance() method is written inside a class to access the instance of the class from other class.
Basically, this is used to ensure that only one instance of the particular class has been created.
e.g., public static Class1 getInstance(Context context){
if(sInstance == null){
sInstance = new Class1(context);
}
return sInstance;
}
* When You need to access any method of this java class Class1, you can call :
Class1.getInstance().method1();
* Here I have used this to implement Singleton Pattern of Java.
Login to rate this answer.