字符串拆分

示例1:

public String[] split(String regex)                           将字符串全部拆分

public String[] split(String regex,int limit)               将字符串全部拆分

 将字符串全部拆分处理

public class StringDemo {
    public static void main(String[] args) {
        String str = "hello world hello mldn";
        String result[] = str.split(" ");   //将字符串全部拆分,按照空格
        for(int x = 0;x < result.length;x ++){
            System.out.println(result[x]);
        }
    }
}

输出1:

hello
world
hello
mldn

猜你喜欢

转载自www.cnblogs.com/yrxns/p/9284955.html