«

ArrayList和数组间的相互转换

时间:2024-3-2 17:38     作者:韩俊     分类: Android


ArrayList和数组间的相互转换

String s = "360001,光大量化核心,GDLHHX,1,1;360003,光大保德信货币,GDBDXHB,2,1;360008,光大增利收益A,GDZLSYA,1,1;360009,光大增利收益C,GDZLSYC,1,1";

    String[] str = s.split(&quot;;&quot;);<br />
    for (int i = 0; i &lt; str.length; i&#43;&#43;) {<br />
        String ss = str[i];<br />
        System.out.println(ss);<br />
    }<br />
    System.out.println(&quot;-------------------------------------------------&quot;);<br />
    String[] abc = new String[] { &quot;张三&quot;, &quot;李四&quot;, &quot;王五&quot; };<br />
    List&lt;String&gt; abcList = new ArrayList&lt;String&gt;(Arrays.asList(abc));<br />
    abcList.retainAll(abcList);<br />
    for (String string : abcList) {<br />
        System.out.println(string.toString());<br />
    }<br />
    System.out.println(&quot;-------------------------------------------------&quot;);<br />
    List&lt;String&gt; lists = Arrays.asList(&quot;张三&quot;, &quot;李四&quot;, &quot;王五&quot;);<br />
    for (int i = 0; i &lt; lists.size(); i&#43;&#43;) {<br />
        System.out.println(lists.get(i));<br />
    }<br />
    System.out.println(&quot;-------------------------------------------------&quot;);<br />
    List&lt;String&gt; list=new ArrayList&lt;String&gt;();  <br />
    list.add(&quot;王五&quot;);  <br />
    list.add(&quot;张三&quot;);  <br />
    list.add(&quot;李四&quot;); <br />
    int size = list.size();<br />
    String[] array = list.toArray(new String[size]);<br />
    for (int i = 0; i &lt; array.length; i&#43;&#43;) {<br />
        System.out.println(array[i]);<br />
    }

标签: android

热门推荐