Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing list from java.awt or java.utils

Tags:

java

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 ??

like image 600
frazman Avatar asked Jan 04 '13 19:01

frazman


People also ask

What is UTIL and awt in Java?

awt.List is a List component used in GUI where as java.util.List is an interface for the lists data structure. Follow this answer to receive notifications.

What is import Java awt?

import java. awt. Graphics means that the Graphics class in the java. awt package is made known to the current class.

Which package provides awt in Java?

The java. awt package provides classes for AWT API such as TextField, Label, TextArea, RadioButton, CheckBox, Choice, List etc. The AWT tutorial will help the user to understand Java GUI programming in simple and easy steps.


2 Answers

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.

like image 78
kosa Avatar answered Oct 05 '22 02:10

kosa


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

like image 31
codeMan Avatar answered Oct 05 '22 04:10

codeMan