import java.util.ArrayList;
public class Details {
public static void main(String[] args) {
//ArrayList<String> Declaration
ArrayList<String> al= new ArrayList<String>();
//add method for String ArrayList
al.add("Ram");
al.add("Shyam");
al.add("CPS");
al.add("John");
al.add("Steve");
System.out.println("Elements of ArrayList of String Type: "+al);
import java.util.ArrayList;
class Main {
public static void main(String[] args){
// create ArrayList
ArrayList<String> languages = new ArrayList<>();
// add() method without the index parameter
languages.add("Java");
languages.add("C");
languages.add("Python");
System.out.println("ArrayList: " + languages);
}
}
import java.util.ArrayList;
import java.util.HashSet;
class Main {
public static void main(String[] args) {
// create a set
HashSet<String> vowels = new HashSet<>();
vowels.add("a");
vowels.add("e");
vowels.add("i");
vowels.add("o");
vowels.add("u");
// create an arraylist
ArrayList<String> alphabets = new ArrayList<>();
// add all elements of set to arraylist
alphabets.addAll(vowels);
System.out.println("ArrayList: " + alphabets);
}
}
List<String> list = List.of("first", "second", "third");
import java.util.ArrayList;
class Main {
public static void main(String[] args){
// create ArrayList
ArrayList<String> Websites = new ArrayList<>();
// add() method without the index parameter
Websites.add("Softhunt.net");
Websites.add("Pythonprogramming.com");
Websites.add("Tutorial.io");
System.out.println("ArrayList: " + Websites);
}
}