Generic Collections : generics « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » generics 
8.22.2.Generic Collections
import java.util.Vector;

public class MainClass {
  public static void main(String[] argv) {
    Vector<Integer> myVec;
    myVec = new Vector<Integer>();

  }
}
8.22.generics
8.22.1.When using generic collections, a cast is not needed to get (declared type) elements out of the collection.
8.22.2.Generic Collections
8.22.3.Arguments of all add() calls made on myVec must be of type MyClass or subclasses of MyClass.
8.22.4.You cannot add non-related class to generic collection instance
8.22.5.When retrieving a member of a generic vector, you can reference without casting.
8.22.6.Iterators may be generic.
8.22.7.Sets can be generic.
8.22.8.Using a generic Iterator to compute the average length of the Strings in a generic Set
8.22.9.Maps may be generic.
8.22.10.The Iterators of the Map's keys and values are generic:
8.22.11.Generics and Enhanced For Loops: for (type varable_name : collection)
8.22.12.You can use more than one parameterized type in a single class definition:
8.22.13.Creating Generic Methods
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.