Mega Code Archive

 
Categories / Java / Generics
 

Unchecked Example

import java.util.*; public class UncheckedExample {     public void processIntVector(Vector<Integer> v)     {         // perform some processing on the vector     }     public static void main(String args[])     {         Vector<Integer> intVector = new Vector<Integer>();         Vector oldVector = new Vector();         UncheckedExample ue = new UncheckedExample();         // This is permitted         oldVector = intVector;         // This causes an unchecked warning         intVector = oldVector;         // This is permitted         ue.processIntVector(intVector);         // This causes an unchecked warning         ue.processIntVector(oldVector);     } }