Create a arraylist that can store only number like int,float,double,etc without any other data type | SoloLearn: Learn to code for FREE!

0

Create a arraylist that can store only number like int,float,double,etc without any other data type

5/22/2020 8:30:50 AM

Ranjeet Singh

5 Answers

New Answer

0

import java.util.List; import java.util.ArrayList; public class Example { public static void main(String[] args) { List<Integer> arrayList = new ArrayList(); arrayList.add(42); System.out.println(arrayList); } } https://www.google.com/amp/s/www.geeksforgeeks.org/list-interface-java-examples/amp/ https://www.w3schools.com/java/java_arraylist.asp https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html https://docs.oracle.com/javase/8/docs/api/java/util/List.html

0

https://code.sololearn.com/cm0LsD6W3VaU/?ref=app

0

... ArrayList<String> listName = new ArrayList<String>(); // наполняем массив данными listName.add("blabla"); listName.add("ohhoho"); listName.add("abrakadabra"); listName.add("tararam"); for (int i = 0; i < listName.size(); i++) System.out.println(listName.get(i)); ...

0

... ArrayList<Double> listName = new ArrayList<Double>(); // наполняем массив данными listName.add(3.14); listName.add(28.54); listName.add(0.265333333); listName.add(1.00009); for (int i = 0; i < listName.size(); i++) System.out.println(listName.get(i)); ...

0

... ArrayList<String> listName = new ArrayList<String>(); ArrayList<Integer> listName = new ArrayList<Integer>(); ArrayList<Double> listName = new ArrayList<Double>(); ....