Thinking in Java Fourth Edition Bruce Eckel Chapter 5 Exercise 2

Exercise 2: Take the code fragments in this section and turn them into a program, and verify that collisions do in fact occur.

package net.mindview.simple;

public class Vector
{
  public Vector()
  {
    System.out.println("net.mindview.simple.Vector");
  }
}
import net.mindview.simple.*;
import java.util.*;
 
public class Collision
{
    public static void main(String[] args)
    {
        // Vector v = new Vector(); // ambiquous collision
        net.mindview.simple.Vector v1 = new net.mindview.simple.Vector();
        java.util.Vector v2 = new java.util.Vector();
    }
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *