Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

list set value at index java

package beginnersbook.com;
import java.util.ArrayList;
public class SetExample {
  public static void main(String args[]) {
    ArrayList<Integer> arraylist = new ArrayList<Integer>();
    arraylist.add(1);
    arraylist.add(2);
    arraylist.add(3);
    arraylist.add(4);
    arraylist.add(5);
    arraylist.add(6);
    arraylist.add(7);
    System.out.println("ArrayList before update: "+arraylist);
    //Updating 1st element
    arraylist.set(0, 11);
    //Updating 2nd element
    arraylist.set(1, 22);
    //Updating 3rd element
    arraylist.set(2, 33);
    //Updating 4th element
    arraylist.set(3, 44);
    //Updating 5th element
    arraylist.set(4, 55);
    System.out.println("ArrayList after Update: "+arraylist);
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: factorial of a number using recursion in java 
Java :: sum of 1D array(JAVA) 
Java :: get type of variable java 
Java :: java convert integer to string 
Java :: remove extra spaces java 
Java :: how to increment character in java 
Java :: java decimalformat 
Java :: java reverse linked list 
Java :: java collection to list 
Java :: java get variable from another class 
Java :: how to get multiple integer input in java 
Java :: what language is android written in 
Java :: java do something after x seconds without stopping everything else 
Java :: android alertdialog setSingleChoiceItems 
Java :: Unsupported Modules Detected 
Java :: how to convert a collection to array in java 
Java :: qr code generator in java 
Java :: javafx stackpane set position 
Java :: java const 
Java :: how to find the sum of an array in java 
Java :: static int java 
Java :: java sealed class 
Java :: object to int java 
Java :: java stream limit items 
Java :: android play sound file from assets 
Java :: java camel case 
Java :: java get all directories in path 
Java :: how to convert milliseconds into second in android studio 
Java :: print an array java 
Java :: timestamp java jpa 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =