Java string split.htm Copyright © tutorialspoint
[Pages:2]JAVA - STRING SPLIT METHOD
Copyright ?
Description:
This method has two variants and splits this string around matches of the given regular expression.
Syntax:
Here is the syntax of this method:
public String[] split(String regex, int limit)
or
public String[] split(String regex)
Parameters:
Here is the detail of parameters:
regex -- the delimiting regular expression.
limit -- the result threshold which means how many strings to be returned.
Return Value:
It returns the array of strings computed by splitting this string around matches of the given regular expression.
Example:
import java.io.*;
public class Test{ public static void main(String args[]){ String Str = new String("Welcome-to-");
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(""); System.out.println("Return Value :" ); for (String retval: Str.split("-")){
System .out.println(retval); } } }
This produces the following result:
Return Value : Welcom e
to-
Return Value : Welcom e to
Return Value: Welcom e to
Return Value : Welcom e to
Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- java string format time
- java string formatting
- java string reverse method
- java string functions
- java string array to string
- java string method
- java string methods list
- python string split each character
- powershell string split options
- python string split regex
- python string split example
- java string split example