java 数组转化为list接口
来源:互联网 发布:银行卡卡号生成软件 编辑:程序博客网 时间:2024/05/22 08:08
1,方法
01
import
java.util.Arrays;
02
import
java.util.List;
03
import
java.util.ArrayList;
04
05
public
class
StringArrayTest
06
{
07
public
static
void
main(String[] args)
08
{
09
String[] words = {
"ace"
,
"boom"
,
"crew"
,
"dog"
,
"eon"
};
10
11
List<String> wordList = Arrays.asList(words);
13
17
}
18
}
2. [代码]比较傻的做法
1
String[] words = { ... };
2
List<String> list =
new
ArrayList<String>(words.length);
3
for
(String s : words) {
4
list.add(s);
5
}
3. [代码]这方法也还可以
1
import
java.util.Collections;
2
3
List myList =
new
ArrayList();
4
String[] myStringArray =
new
String[] {
"Java"
,
"is"
,
"Cool"
};
5
6
Collections.addAll(myList, myStringArray);
推荐使用第一种;
0 0
- java 数组转化为list接口
- Java中将数组转化为List
- 数组转化为List
- JAVA—list集合转化为Java数组
- 数组转化为List示例
- groovy list转化为数组
- 如何将list转化为数组
- 如何将list转化为数组
- 将List转化为数组的若干问题
- 范型List 转化为数组的demo
- 将List数组转化为datatable
- 关于List集合转化为数组
- Java Map集合 转化为List 并为List排序
- JAVA将list转化为xml文件
- php json接口转化为数组 生成xml接口
- 把java数组转化成List
- Java数组、List的转化合并
- Java中List与数组互相转化
- PhoneGap插件开发示例(iOS)
- erlang基础知识点
- 一个程序员在卖软件服务中学到的销售经验
- Zookeeper源码分析(8)- CommitProcessor
- android aapt用法
- java 数组转化为list接口
- java比较器Comparable接口和Comaprator接口
- erlang运算符
- Android Application基础
- NGUI学习笔记(二)UISprite
- Zookeeper源码分析(9)- ToBeAppliedRequestProcessor
- 出现ORA-12154: TNS:could not resolve the connect identifier specified 连接错误
- 当DG进行failover之后重新恢复DG(利用rman 11gduplicate的ADG特性)
- Zookeeper源码分析(10)- FinalRequestProcessor