Error regarding import statements...

Hi

This seemed a bit wierd to me.

The first code snippet makes sense but not the second one...

This code snippet doesnt compile because of error "single-type import"

import java.util.Iterator;

import java.util.Vector;

import mypkg.Vector;

class t12 {}

[t12.java: java.util.Vector is already defined in a single-type import

import mypkg.Vector;]

2nd code snippet

import java.util.Iterator;

import java.util.*;

import mypkg.Vector;

class t12 {}

Compiles properly..

I am not very sure...shouldnt the comile flag this as well as error

Anu thoughts on this?

-sbelur

[678 byte] By [belur_1da] at [2007-10-3 9:23:34]
# 1

This is fine:

import java.util.*;

import mypkg.Vector;

because if you use the Vector class it will not be Ambigious to the compilier, because you have specifically stated what you wanted.

When you do this:

import java.util.Vector;

import mypkg.Vector;

The compiler doesn't know which one to use. Just like when you do this:

import java.util.*;

import mypkg.*;

zadoka at 2007-7-15 4:37:24 > top of Java-index,Developer Tools,Java Compiler...