zoukankan      html  css  js  c++  java
  • 112、Java中String类之字符串文本拆分为指定的个数

    01.代码如下:

    package TIANPAN;
    
    /**
     * 此处为文档注释
     *
     * @author 田攀 微信382477247
     */
    public class TestDemo {
        public static void main(String args[]) {
            String str = "hello yootk nihao mldn";    // 定义字符串,中间使用空格作为间隔
            String result[] = str.split(" ", 2);        // 字符串拆分
            for (int x = 0; x < result.length; x++) {    // 循环输出
                System.out.println(result[x]);
            }
        }
    }

    02.效果如下:

    知识有价,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢。

  • 相关阅读:
    8月10日
    8月9日
    8月8日
    8月7日
    8月6日
    8月5日
    《大道至简》读后感
    8月4日
    8月3日
    8月2日
  • 原文地址:https://www.cnblogs.com/tianpan2019/p/12332004.html
Copyright © 2011-2022 走看看