fyqt.net
当前位置:首页 >> 数组拼接成字符串 >>

数组拼接成字符串

这样 for(i=0;i

public class Hello{public static void main(String[] args){String str = "a,b,c,d";String[] arr = new String[str.replaceAll(",","").length()];String result = "";for(int i = 0; i < arr.length; i++){arr[i] = str.replaceAll(",","")....

因为你在split中没有定义分割符,会默认空格作为分割符,第一项就会是个空格。

public static void main(String[] args) {int[] nums = {1,2,4,5};String str = "";for (int i = 0; i < nums.length; i++) {str += nums[i];}System.out.println(str);}

public static void main(String[] args) { int[] nums = {1,2,4,5}; String str = ""; for (int i = 0; i < nums.length; i++) { str += nums[i]; } System.out.println(str); }

用c#或java这样的语言直接把数组遍历转换为字符串然后与目标字符串再连接就行 例如java int[] temp = {1,22,3990,23,4}; StringBuilder objString = new StringBuilder("字符串连接数组"); for(int i=0;i

你是不是这个意思: string[] arr = { "a","b","c","d"}; string s = string.Empty; foreach (string str in arr) { s = s + str; } Console.WriteLine(s);

String [] strArray = new String []{"1","a","s","2","d"}; String str = ""; for (int i = 0; i < strArray.length; i++) { str = str+ strArray[i]; } System.out.println(str);

java可以使用两种方法直接将字符数组转为字符串 方法1:直接在构造String时转换。 char[] data = {'a', 'b', 'c'}; String str = new String(data); 方法2:调用String类的方法转换。 String.valueOf(char[] ch)

NSString *string = [array componentsJoinedByString:@","];--分隔符

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