Answers for "append in java arraylist"

4

java append to list

package com.journaldev.examples;

import java.util.ArrayList;
import java.util.List;

public class ListAddExamples {

	public static void main(String[] args) {

		List<String> vowels = new ArrayList<>();

		vowels.add("A"); // [A]
		vowels.add("E"); // [A, E]
		vowels.add("U"); // [A, E, U]

		System.out.println(vowels); // [A, E, U]

		vowels.add(2, "I"); // [A, E, I, U]
		vowels.add(3, "O"); // [A, E, I, O, U]

		System.out.println(vowels); // [A, E, I, O, U]
	}
}
Posted by: Guest on October-29-2020
1

arraylist add

ArrayList<String> languages = new ArrayList<String>(); 
languages.add("PHP");
languages.add("JAVA");
languages.add("C#");
ArrayList<int> numbers = new ArrayList<int>(); 
numbers.add(9);
numbers.add(14);
numbers.add(2);
Posted by: Guest on June-17-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language