Java String split(String regex, int limit) 方法


Java String split(String regex, int limit) 方法

import java.io.*;

public class Test {



   public static void main(String args[]) {

      String Str = new String("Welcome-to-codingdict.com");

      System.out.println("Return Value :" );



      for (String retval: Str.split("-", 2)) {

         System.out.println(retval);

      }

      System.out.println("");

      System.out.println("Return Value :" );



      for (String retval: Str.split("-", 3)) {

         System.out.println(retval);

      }

      System.out.println("");

      System.out.println("Return Value :" );



      for (String retval: Str.split("-", 0)) {

         System.out.println(retval);

      }

      System.out.println("");

   }

}