Saturday, 8 August 2015

Generic Class in Java






Generic Class

  • In this picture as we can see we have three different clots for driver, if you put slotted than you can fix that pin, if you put crossed on driver than you can fix that pin and so on.
  • Just like we have generic class which says that you build class one time and that class for all different object like String, Int, Float etc.
  • Suppose, we have one list program define for int object but now you are in need of same list for String Object or double Object than every time define same thing for different Object is difficult for us.So what we should do that create generic class.
  • Create generic class and use that for different datatypes or Object.How we can implement that is as below.

  • Generic class

    Main class

No comments:

Post a Comment