Answers for "java arraylist print one element"

6

print arraylist java

Arrays.toString(list.toArray())
Posted by: Guest on April-27-2020
1

how to select a element in an arraylist java

import java.util.ArrayList;
import java.util.Arrays;
 
public class ArrayListExample 
{
    public static void main(String[] args) 
    {
        ArrayList<String> list = new ArrayList<>(Arrays.asList("alex", "brian", "charles", "dough"));
         
        String firstName = list.get(0);         //alex
        String secondName = list.get(1);        //brian
         
        System.out.println(firstName);
        System.out.println(secondName);
    }
}
Posted by: Guest on May-18-2020

Code answers related to "java arraylist print one element"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language