Design Pattern

Single Ton Design Pattern   :- Instead of creating multiple Object we can create Singleton Object and use it for multiple requirements.

Realtime examples :-RunTime

class Singleton
{
private static Singleton singleton=null;
private Singleton
{

}
public Singleton getSingleton()
{
if(singleton==null)
{
singleton=new Singleton();
}
return singleton;
}

Immutable Class:-  String is immutable class if we are trying to change with those changes a new object will create

ex for own immutable class

final Class Test
{
private int i;
Test(int i)
{
this.i=i;
}
public Test getTest(int i)
{
if(this.i=i)
{
return this;
}
else
return new Test(i);
}
}