首页 > 编程语言 > 详细

Java 实例 - 字符串分割

时间:2018-03-03 14:38:02      阅读:193      评论:0      收藏:0      [点我收藏+]
package string;

public class split {
    public static void main(String[] args) {
        /**
         * 字符串的分割
         */
        String str = "www.baidu.com";
        String[] temp = str.split("\\.");// "."和“|”都需要加上\\转译
        for (int i = 0; i < temp.length; i++) {
            System.out.println(temp[i]);
        }
        System.out.println("============使用for each==========");
        String str1 = "abc-cdef-ghij";
        String[] temp1 = str1.split("-");
        for (String x : temp1) {
            System.out.println(x);
        }
    }

}

 

Java 实例 - 字符串分割

原文:https://www.cnblogs.com/zhuxiaopang/p/8496384.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!