xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to create a list in Java
Java Online Editor
Execute Code
More Java Sample Codes
import java.util.ArrayList; import java.util.List; public class ExampleApp { public static void main(String[] args) { // Create a list of strings List<String> fruits = new ArrayList<String>(); // Add elements to the fruit list fruits.add("Apple"); fruits.add("Banana"); fruits.add("Mango"); fruits.add("Orange"); // Access elements of the list using a for loop for (String item : fruits) { System.out.println(item); } // Access elements of the list using element list index number System.out.println(fruits.get(2)); } }