40

I am new to java so maybe this is very trivial question.

But I just noticed that when i declared

List myList = new ArrayList();

Eclipse IDE gave me bunch of options for "List" error.

Mainly.. the top 2 one got me curious.

What is the difference if I use java.awt vs java.utils ??

4

4 回答 4

51

java.awt.List is List component (like drop down list), it not a collection/datastructure.

What is the difference if I use java.awt vs java.utils ??

You can't use List/Collection specific methods like iterator.

于 2013-01-04T19:35:46.043 回答
4

awt.List is a List component used in GUI where as java.util.List is an interface for the lists data structure

于 2013-01-04T19:36:38.507 回答
1

java.awt.List is an awt component. Don't use it in your case. You need java.util.List.

于 2013-01-04T19:36:16.560 回答
0

AWT 或抽象窗口工具包是 java 中的 GUI 工具包,包含 2D 元素所需的类。awt.list 用于获取应用程序中的选择框/下拉列表。

在您的情况下使用 util.list 。

于 2019-09-07T11:57:53.203 回答