Answers for "array in list java"

3

convert array to list java

/*
Get the Array to be converted.
Create the List by passing the Array as parameter in the constructor of the List with the help of Arrays. asList() method.
Return the formed List.
*/

String[] namedata = { "ram", "shyam", "balram" }; 

List<String> list = Arrays.asList(namedata);
Posted by: Guest on May-07-2020
15

java arraylist

import java.util.List; //list abstract class
import java.util.ArrayList; //arraylist class

//Object Lists
List l = new ArrayList();
ArrayList a = new ArrayList();

//Specialized List
List<String> l = new ArrayList<String>();
ArrayList<Integer> a = new ArrayList<Integer>();
//only reference data types allowed in brackets <>

//Initial Capacity
List<Double> l = new ArrayList<Double>(5);
//list will start with a capacity of 5
//saves allocation times
Posted by: Guest on July-13-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language