clwn.net
当前位置:首页 >> list转为string >>

list转为string

假设你的list变量名是list StringBuffer sb=new StringBuffer(); for(String item:list){ sb.append(item); } // sb.toString() 就是你要的字符串; String[] arr=new String[list.size()]; for(int i=0;i

String abc = "aaa,bbb,ccc"; String[] arr = abc.split(","); List list = java.util.Arrays.aslist(abc);

假设你的list变量名是list StringBuffer sb=new StringBuffer(); for(String item:list){ sb.append(item); } // sb.toString() 就是你要的字符串; String[] arr=new String[list.size()]; for(int i=0;i

import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Test { public static void main(String[] a) { String [] s=new String[] {"1","2"}; List l=new ArrayList(); l=Arrays.asList(s); System.out.pr...

import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class StringTest { public static void main(String[] args) { ArrayList packagesArray = new ArrayList(); packagesArray.add("1"); packagesArray.add...

是这样的吗,把字符串数组转成字符串集合 String[] words = {"a","b","c","d","e"}; List list = Arrays.asList(words); for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); }//顺便一说,定义list的时候你也可以不指定...

假设你的list变量名是list StringBuffer sb=new StringBuffer();for(String item:list){sb.append(item);}// sb.toString() 就是你要的字符串;

List list = new ArrayList(); //list中添对象 list.add("a"); list.add("b"); list.add("c"); StringBuffer sb = new StringBuffer(); for(String s:list){ sb.append(s) } System.out.println(sb.toString());

public static void main(String[] args) { List objs = new ArrayList(); List strs = new ArrayList(); for (int i = 0; i < objs.size(); i++) { strs.add(String.valueOf(objs.get(i)));//这是把集合Object对象转换成String放入新的集合中。...

1、你问题可能没有描述清楚 2、String 转成 List List list = new ArrayList();list.add(str); // str表示字符串3、List 转 String for(String str : list) // 这里要保证list为String集合{ System.out.println(str);}

网站首页 | 网站地图
All rights reserved Powered by www.clwn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com