1. 程式人生 > >字符串拆分

字符串拆分

示例 輸出 字符串拆分 rgs div world pan out 空格

示例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

字符串拆分