Relationship
List is Java Interface, ArrayList is Java Class, and they all belong to the Java.util package.
The Java List is an ordered set (ordered collection), also known as a sequence (Sequence);
Java ArrayList is a variable-sized array implementation of the Java List Interface.
Both of these are in the JAVA collection framework location, as shown in:
Take a look at the Official document description:
Java.util
Interface list<e>
E-the type of elements in this list
All superinterfaces:
Collection<e>, iterable<e>
All known implementing Classes:
Abstractlist, Abstractsequentiallist, ArrayList, AttributeList, Copyonwritearraylist, LinkedList, RoleList, Roleunresolvedlist, Stack, Vector
public interface list<e>
Extends collection<e>
An ordered collection (also known as a sequence).
Java.util
Class arraylist<e>
- Java.lang.Object
- Java.util.abstractcollection<e>
- Java.util.abstractlist<e>
All implemented Interfaces:
Serializable, Cloneable, Iterable<e>, Collection<e>, List<e>, randomaccess
Direct known subclasses:
AttributeList, Rolelist, roleunresolvedlist
public class Arraylist<e>
Extends abstractlist<e>
Implements List<e>, Randomaccess, Cloneable, Serializable
Resizable-array implementation of the List interface.
Example
1. Create a new ArrayList object
New Arraylist<string> ();
2. Adding elements to them
Brands.add ("Jack Amber");
3. Complete Example
//Beerexpert.java, excerpted from Dawn Griffiths & David Griffiths, "Head first Android development",Importjava.util.ArrayList;Importjava.util.List; Public classBeerexpert {List<String>getbrands (String color) {List<String> brands =NewArraylist<string>(); if(Color.equals ("Amber") {Brands.add ("Jack Amber."); Brands.add ("Red Moose"); } Else{Brands.add ("Jail Pale Ale"); Brands.add ("Gout Stout"); } returnbrands; }}
References
[1] Oracle Corporation. Class arraylist<e>-Java? Platform Standard Ed. 8 [OL]. Https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html
[2] Oracle Corporation. Interface list<e>-Java? Platform Standard Ed. 8 [OL]. Https://docs.oracle.com/javase/8/docs/api/java/util/List.html
[3] Stack Overflow Users. Type List vs type ArrayList in Java [OL]. Https://stackoverflow.com/questions/2279030/type-list-vs-type-arraylist-in-java
ArrayList and List relationships and code examples-Java