本文介绍了在java中的ArrayList转换到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有像ABCD#XYZ和MNOP#QRS的价值观的ArrayList。我想把它转换成一个数组,然后用#作为分隔符分割,并在另一个数组的数组和XYZ,QRS有ABCD,MNOP。我尝试以下code:
I have an ArrayList with values like "abcd#xyz" and "mnop#qrs". I want to convert it into an Array and then split it with # as delimiter and have abcd,mnop in an array and xyz,qrs in another array. I tried the following code:
String dsf[] = new String[al.size()];
for(int i =0;i<al.size();i++){
dsf[i] = al.get(i);
}
但它没有说Ljava.lang.String; @ 57ba57ba
But it failed saying "Ljava.lang.String;@57ba57ba"
您可以帮我请。
推荐答案
您不必推倒重来,的的在的toArray()
方法:
You don't need to reinvent the wheel, here's the toArray()
method:
String []dsf = new String[al.size()];
al.toArray(dsf);
这篇关于在java中的ArrayList转换到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!