View RSS Feed

Recent Blogs Posts

  1. Bounding ArrayList

    by , 11-13-2011 at 11:45 AM (My Java Tips)
    Collections can be of a particular type i.e they are only allowed to hold objects of a defined type. This is called “bounded by”. For example:

    Java Code:
    ArrayList  arrayList  = new  ArrayList();
    Vector  vector  = new  Vector();


    We declared an ArrayList and a Vector both bounded by String. We cannot store objects other than String in these. Lets try to store an integer in Vector and see what happens.

    Java Code:
    Vector  vector  = new  Vector();
    ...