A wrapper class is "encapsulate" the resource. and restrict the interface between outside the world and
encapsulate the object.
public class Wrapper
{
private int x = 10;
private int y = 20;
public Wrapper()
{
//
// TODO: Add constructor logic here
//
}
public int add(int x, int y)
{
Wrapper.inside obj = new inside();
//core functionality of this method is written in the wrapped class.
int sum = obj.add(x, y);
return sum;
}
///
/// this class is wrapped by the wrapper class.
/// we can access only inside this class.
/// outside the class, we cant access this class.
///
private class inside
{
public int add(int x, int y)
{
return x + y;
}
}
}