Wrapper class example

Description :


This code shows example of wrapper class


/// Example for Wrapper class

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;
}
}
}


Comments

Guest Author: Rahul Ranjan15 Apr 2012

Nice article...Only Example that is understandable for Wrapper class...!!

Guest Author: priya12 Jun 2012

Gud article.easy to understand ...



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: