集册 Java实例教程 使用逗号拆分字符串,创建并返回字符串数组列表。

使用逗号拆分字符串,创建并返回字符串数组列表。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

392
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用逗号拆分字符串,创建并返回字符串数组列表。


//package com.nowjava;

import java.util.ArrayList;
/** from 
时代Java公众号 - N o w J a  v a . c o m**/


public class Main {

    public static void main(String[] argv) throws Exception {

        String item = "nowjava.com";

        System.out.println(split(item));

    }


    /**

     * Splits the string using a comma, creates and returns an array list of strings.

     * @param item

     * @return

     */

    public static ArrayList<String> split(String item) {/**来自 N o  w  J a v a . c o m - 时  代  Java**/

        ArrayList<String> list = new ArrayList<String>();

展开阅读全文