// List转换为String数组
List<String> list = new ArrayList<String>();
list.add("a1");
list.add("a2");
String[] toBeStored = list.toArray(new String[list.size()]);
for(String s : toBeStored) {
System.out.println(s);
}
// String数组转换为List
String[] arr = new String[] {"1", "2"};
List list = Arrays.asList(arr);

说明:这个转换仅限于相同类型的转换。

参考:

http://blog.csdn.net/aaronuu/article/details/7055650

Java下String和List<String>的互相转换的更多相关文章

  1. hadoop ha环境下的datanode启动报错java.lang.NumberFormatException: For input string: "10m"

    hadoop ha环境启动start-dfs.sh的时候datanode启动不了,并且报错. [hadoop@datanode2 ~]$ cat /home/hadoop/hadoop-2.7.3/l ...

  2. Java下List<Long>转List<String>或者List<Long>转List<Integer>

    说明:很遗憾,没有快速方法,只能遍历然后循环增加进去. 方法: for(String str : list) { int i = Integer.paseInt(str); intList.add(i ...

  3. Java下String逗号数组和List<String>的互相转换

    说明:很遗憾,组装的时候只能遍历. 方法: public static String listToString(List<String> list){ if(list==null){ re ...

  4. java.lang.NumberFormatException: For input string:"filesId"

    做项目时候,页面获取出现了这个问题.找了好久一直以为是我字段或者是数据库字段问题导致引起的. 最后才发现是 struts2中jsp我写错了一个参数,一直导致报错.后来改了就好了. 当大家遇到这个问题的 ...

  5. java.lang.ClassFormatError: Illegal UTF8 string in constant pool in class file Server/Request

    Linux服务器上,将本地编译好的文件上传后,Tomcat启动时报错: Exception in thread "Thread-2" java.lang.ClassFormatEr ...

  6. Java JVM 请别拿“String s=new String("z");创建了多少实例”来面试 [ 转载 ]

    Java 请别再拿“String s = new String("xyz");创建了多少个String实例”来面试了吧 [ 转载 ] @author RednaxelaFX 原文链 ...

  7. java中String s = new String("abc")创建了几个对象?

    答案是两个,现在我们具体的说一下: String s = new String("abc");一.我们要明白两个概念,引用变量和对象,对象一般通过new在堆中创建,s只是一个引用变 ...

  8. java基础进阶一:String源码和String常量池

    作者:NiceCui 本文谢绝转载,如需转载需征得作者本人同意,谢谢. 本文链接:http://www.cnblogs.com/NiceCui/p/8046564.html 邮箱:moyi@moyib ...

  9. Java基础之引用(String,char[],Integer)总结

    1.String的引用: 下列代码执行后的结果为: public class Test { public static void main(String[] args) { StringBuffer  ...

随机推荐

  1. PHP设计模式-代理模式

    概念理解: 代理模式,是对简单处理程序(或指针)的增强,用于引用一个对象:这个指针被代理对象取代,代理对象位于客户端和真实程序之间,指针有一个可被多个目标利用的钩子. 参与者: client(参与者) ...

  2. 51Nod 1081前缀和

    #include <iostream> #include <stdio.h> using namespace std; ]; ]; int main() { int n; ci ...

  3. thinkpad x260 U盘进入

    主要有三个问题: 1.bios 不支持U盘启动 联想电脑bios设置u盘启动方法如下:1.打开联想笔记本电脑,在出现开机画面时按F2进入bios设置界面,使用左右方向键将光标移至security菜单, ...

  4. Java并发编程--ThreadPoolExecutor

    概述 为什么要使用线程池? 合理利用线程池能够带来三个好处.第一:降低资源消耗.通过重复利用已创建的线程降低线程创建和销毁造成的消耗.第二:提高响应速度.当任务到达时,任务可以不需要等到线程创建就能立 ...

  5. bzoj3918 [Baltic2014]Postman

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3918 [题解] 每日至少更一题啊qwq凑任务(迷 明显猜个结论:随便搜环就行了 然后搜环姿势 ...

  6. bzoj 1044 贪心二分+DP

    原题传送门http://www.lydsy.com/JudgeOnline/problem.php?id=1044 首先对于第一问,我们可以轻易的用二分答案来搞定,对于每一个二分到的mid值 我们从l ...

  7. [设计模式-行为型]观察者模式(Observer)

    一句话 事件监听就是观察者模式最好的例子. 概括

  8. linux--redis的安装和配置和开启多个端口

    在workerman开发过程中需要安装redis来存储用户ip.端口等信息 首先UBUNTU中安装redis: apt-update  //更新apt包源apt-get install redis-s ...

  9. php使用memcached详解

    一.memcached 简介 在很多场合,我们都会听到 memcached 这个名字,但很多同学只是听过,并没有用过或实际了解过,只知道它是一个很不错的东东.这里简单介绍一下,memcached 是高 ...

  10. Square Number & Cube Number

    Square Number: Description In mathematics, a square number is an integer that is the square of an in ...