Whenever I import java.awt.* and try to use a List I get an error.
Is there any way to import java.awt.* and use a List?
On
The class name List is now ambiguous because there are two classes java.awt.List and java.util.List. You can resolve the ambiguity by adding a specific import of the class name:
import java.awt.*;
import java.util.*;
import java.util.List;
However, if you need to refer to both java.awt.List and java.util.List in the same source file, then you have crossed the limits of the import mechanism. You can use an import statement to shorten one of the names to List, but you need to reference the other by its full name whenever it occurs in the source text.
There is an ambiguity in the naming conventions of List in class awt and util, so we can handle it in 2 ways:
Use import
import java.awt.*;import java.util.List;import java.util.*;Use the full path, as mentioned in Head First Java,"either use import or the full name"
java.util.List<String> list = new java.util.ArrayList<String>();