UncheckedExample.java Source code

Java tutorial

Introduction

Here is the source code for UncheckedExample.java

Source

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);
    }
}