Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Java List Access Elements using get() method

// Java Program to Add Elements to a List

// Importing all utility classes
import java.util.*;

// Main class
class Main {

	// Main driver method
	public static void main(String args[])
	{
		// Creating an object of List interface,
		// implemented by ArrayList class
		List<String> list = new ArrayList<>();

		// Adding elements to object of List interface
		// Custom elements
		list.add(0, "Apple");
		list.add(1, "Banana");
	    list.add(2, "Mango");

		// Print all the elements inside the
		// List interface object
		System.out.println("ArrayList: " + list+"
");
		
		// get the element from the arraylist
        String str = list.get(1);
        System.out.print("Element at index 1: " + str);
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: java stream findany 
Java :: broadcast receiver for no interner android studio 
Java :: java creating an object 
Java :: get selected item spinner 
Java :: what is construct in java 
Java :: java compile 
Java :: how to read space separated integers in java 
Java :: what is jar file in java 
Java :: how to set the length to int array in java 
Java :: zoneddatetime java 
Java :: what is encapsulation in java 
Java :: java comment 
Java :: Java char Keyword 
Java :: spring login response data 
Java :: valid parentheses leetcode solution java 
Java :: java literals 
Java :: instantiation in java 
Java :: long in java 
Java :: java code to get all leaf nodes of a xml 
Java :: androi amterila inpout dialgue to get inouti diaogue 
Java :: start hadoop and yarn with java 
Java :: spring boot initializr-generator example 
Java :: java inser at index 
Java :: one space diagonally in java 
Java :: reverse words in a string java 
Java :: Java Catching base exception class only 
Java :: sha1 
Java :: difference between final and constant in java 
Java :: ExpandableLayout in android 
Java :: java lambda expression in priorityqueue 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =