Answers for ".add in java"

3

ArrayList add(int index, E element) method in java

import java.util.ArrayList;
public class ArrayListAddMethodExample
{
   public static void main(String[] args)
   {
      // creating an empty ArrayList with initial capacity
      ArrayList<Integer> al = new ArrayList<Integer>(6);
      al.add(12);
      al.add(14);
      al.add(16);
      al.add(18);
      al.add(20);
      // adding element 15 at fourth position
      al.add(3, 15);
      for(Integer number : al)
      {
         System.out.println("Number: " + number);
      }
   }
}
Posted by: Guest on October-30-2020
1

how to addin java

int x = 20; // makes x = to 20, while making 20 an integer instead of a string
int y = 21; // same as x
System.out.println("Addition =" x + y);
Posted by: Guest on February-16-2021
0

arraylist add method

public void add(int index, E element)	// no return value
Posted by: Guest on May-16-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language