Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Java List Replace at Index using set() function

// 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+"
");
		
        // change the element of the array list
        list.set(1, "Orange");
        System.out.println("Modified ArrayList: " + list);
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: problem solving using recursion in java 
Java :: string in java 
Java :: default constructor java 
Java :: convert kotlin to java online 
Java :: java binary search tree 
Java :: odd numbers in java 
Java :: java optional parameters 
Java :: autowired in spring 
Java :: set preference value android 
Java :: date data type in java 
Java :: java string stringbuilder remove trailing comma 
Java :: java enum from int 
Java :: casting in java 
Java :: java printstacktrace 
Java :: java hello world program 
Java :: java coding standards for classes 
Java :: x = x + y; in java 
Java :: java random value threadlocalrandom 
Java :: java 8 list to map with occurrences 
Java :: how to create simple java bean class for login page in eclipse 
Sql :: get database size mysql 
Sql :: convert utc to est sql 
Sql :: safe update mode in mysql 
Sql :: mysql alter table add index 
Sql :: mysql return 0 if null 
Sql :: find largest table in mysql database 
Sql :: sql server check version 
Sql :: postgres regex remove special characters 
Sql :: convert_tz mysql 
Sql :: postgres get month name from date 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =