Java type list is ambiguous?

14,817

Solution 1

Add import java.awt.List; to your import statements. This should work fine then.

This is mainly because there is a java.util.List and a java.awt.List. Since you are importing both of them using wildcards, the compiler doesn't know which one you actually want to.

Solution 2

The reason that you get the "ambiguous" message is because there is a List class in both "java.awt." and the "java.util." packages that are at the top of the import list.

To solve this issue you should pick one of them that most likely is being used in the application (I would guess java.awt.List.

In eclipse if you do a "CTRL + SHIFT + o" (that's an o not a zero), it will refactor your imports. From there you can select the java.awt.List.

Share:
14,817
inquirydroid
Author by

inquirydroid

Updated on August 18, 2022

Comments

  • inquirydroid
    inquirydroid over 1 year

    I am a programming enthusiast with a basic programming background, but I'm completely new to the Java programming language.

    I want to learn how a simple web crawler is built and I'm using this site to compile the source to see how it works and see it in action! http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/#demo

    The source provided by the website is here: http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/WebCrawler.java

    I am running eclipse 3.2 and using the sun-java-6 JRE to compile applets. I am running on Crunchbang, a Ubuntu distro.

    There is some part of the library that I am unfamiliar with and do not know how to fix.

    List listmatches;
    

    The error says that "The type List is ambiguous".

    I have the package java.utils.*; but the error still persist.

    Is there something wrong with my syntax or is there a new syntax for List?

  • inquirydroid
    inquirydroid almost 13 years
    Thanks, it worked. I still relatively new and a quick google said util instead of awt