Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java type list is ambiguous?

Tags:

java

list

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?

like image 473
inquirydroid Avatar asked May 18 '11 17:05

inquirydroid


2 Answers

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.

like image 139
Thomas Jungblut Avatar answered Oct 30 '22 04:10

Thomas Jungblut


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.

like image 40
amischiefr Avatar answered Oct 30 '22 05:10

amischiefr