Hi Run the following three codes, you will find the difference 1) Vector<Integer> v = new Vector<Integer>();
v.add("sdgfas"); v.add(124); Iterator itr = v.iterator(); while(itr.hasNext()) { System.out.println(itr.next()); } 2) Vector<String> v = new Vector<String>(); v.add("sdgfas"); v.add(124); Iterator itr = v.iterator(); while(itr.hasNext()){ System.out.println(itr.next()); } 3) Vector v = new Vector(); v.add("sdgfas"); v.add(124); Iterator itr = v.iterator(); while(itr.hasNext()){ System.out.println(itr.next()); } Error will be shown at compile time only. Thank You Regards Rahul Singh -----Original Message----- From: javaprogrammingwithpassion@googlegroups.com [mailto:javaprogrammingwithpass...@googlegroups.com] On Behalf Of Lawrence Louie Sent: Friday, October 15, 2010 5:06 AM To: Java Programming Online Training Course By Sang Shin Subject: [java programming] question on Generics Hi, >From reading the Generic subject, it seems to me Generic here refers to the type that's assigned to a collection which will prevents ClassCastException. Ex: Vector<String> vs = new Vector<String>(); For example, in the sample code above, we are using a Generic of type string assign to the vector. Is my understanding correct here about Generic? Thx. Lawrence -- To post to this group, send email to javaprogrammingwithpassion@googlegroups.com To unsubscribe from this group, send email to javaprogrammingwithpassion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en Mahindra Satyam powered IT for the 2010 FIFA World Cup(TM). To learn more, visit: www.mahindrasatyam.com/fifa/index.asp DISCLAIMER: This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. -- To post to this group, send email to javaprogrammingwithpassion@googlegroups.com To unsubscribe from this group, send email to javaprogrammingwithpassion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en