I use a mass import class group as below:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
import java.text.*;
import java.util.regex.*;
This way I don’t have to worry about leaving any classes out.
Then when I used List I got this error:
reference to
Listis ambiguous, both classjava.util.Listinjava.util
and classjava.awt.Listinjava.awtmatch
How do I fix this? Is there a way to deport one of the classes? Which one is better?
You will need to refer to these types with their fully qualified names,
java.util.Listandjava.awt.List, throughout this class file.This will disambiguate the two
Lists so that it won’t strictly be necessary to “deport” anything (yourimportstatements can stay the same). However I do agree with the other answer’s recommendations that you tidy up your imports.If one of the
Lists was “deported” then that would let you refer to the otherListby its short name.