www.qprq.net > jAvA中Arrylist怎么存储DouBlE

jAvA中Arrylist怎么存储DouBlE

集合中只能存放对象,你可以double的包装类Double类型的! ArrayList doubleList = new ArrayList();

ArrayList 这个集合里面只能是Double类型的,怎么可能往里面添加String字符串??? 排序 直接sort

package test;import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class InputTest {public static void main(String[] args) {Scanner in = new Scanner(System.in);String line = null;List persons = new Ar...

for ( int i = 0; i < arrayList.size(); i++){ System.out.println(arrayList.get(i)); }

import java.util.*; public class ArrayAsListDemo { public static void main(String[] args) { Integer[] arr = {1, 3, 5, 7, 9}; List lis = Arrays.asList(arr); System.out.println(lis); } }

通过遍历的方法就可以打印出来。 工具: eclipse 参考代码及注释如下: package com.ldc.test; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) { Float[] fl1=new Float[3];/...

import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class NewTxt { public static void main(String[] args) throws IOException { int n = 5; ...

import java.util.*; public class Test { public static void main(String[] args) { List Num_num = new ArrayList(); List Num = new ArrayList(); String Str1 = "12"; String Str2 = "34"; Num.add(Str1); Num.add(Str2); for(int i = 0; i...

1:直接调用list.toArray()? 2:遍历 List list = new ArrayList() String[] arr = new String[list.size()]; for(int i=0;i

List fl = new ArrayList(); // 泛型,这ArrayList只能放Float类型 fl.add(1.0f); Float[] f = new Float[fl.size()]; for (int i = 0; i < fl.size(); i++) { f[i] = fl.get(i); } System.out.println(f.length);

网站地图

All rights reserved Powered by www.qprq.net

copyright ©right 2010-2021。
www.qprq.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com