1. Until 1.4 version we have ArrayList class with the declarations as follows.

    http://www.grecorailings.com/?fartyx=%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D8%AC-%D8%A7%D9%84%D8%B1%D8%A7%D8%AC%D8%AD%D9%8A-%D9%84%D9%84%D9%85%D8%B1%D8%A7%D8%A8%D8%AD%D8%A9-%D9%81%D9%8A-%D8%A7%D9%84%D8%A7%D8%B3%D9%87%D9%85&86d=b4 برنامج الراجحي للمرابحة في الاسهم class ArrayList{ add(Object o); Object get(int index); }

  2. add() method contain Object as argument, hence we can add any kind of object.
  3. As a result we can’t get any type safety. The return type of get() method is object hence at the time of retrieval we should perform typecasting.
  4. But in the 1.5 version we have generic ArrayList class with the definition as follows.

    هامور الاسهم السعودية class ArrayList<T>{ add(T t); T get(int); }

  5. Based on run time requirement the corresponding version of ArrayList will loaded.

    http://freshgiants.com/?komyuniti=%D8%A7%D9%84%D8%AA%D8%AC%D8%A7%D8%B1%D8%A9-%D8%A7%D9%84%D8%B9%D9%84%D9%85%D9%8A%D8%A9-%D9%84%D9%84%D8%A7%D8%B3%D9%87%D9%85 التجارة العلمية للاسهم ArrayList<String> l = new ArrayList<String>();</li>

  6. For the following declarations the corresponding loaded class is

    http://apseng.com.au/?pisywka=%D9%83%D9%8A%D9%81-%D8%A7%D8%B4%D8%AA%D8%B1%D9%8A-%D8%A7%D8%B3%D9%87%D9%85-%D8%AA%D9%88%D9%8A%D8%AA%D8%B1&495=40 كيف اشتري اسهم تويتر class ArrayList<String>{ add(String); String get(int); }

  7. The argument to the add method is String hence we should add only String Object as the result we will get type safety.
  8. The return type of get() method is String. Hence at the time of retrieval no need to perform typecasting.
  9. We can define our own generic classes also.

    http://www.kmemfm.com/?pilotka=forex-probability forex probability class GenClass<T> { T ob; GenClass(T ob) { this.ob = ob; } public void show() { System.out.println("The type of Object is : " + ob.getClass().getName()); } public T getOb() { return ob; } } class GenericDemo { public static void main(String[] args) { GenClass<String> g1 = new GenClass<String>("Java"); g1.show(); System.out.println(g1.getOb()); GenClass<Integer> g2 = new GenClass<Integer>(10); g2.show(); System.out.println(g2.getOb()); } } /*Output: The type of Object is : java.lang.String Java The type of Object is : java.lang.Integer 10 */