Check out example codes for "split method in java". It will help you in understanding the concepts better.

Code Example 1

String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556

Code Example 2

// Java program to demonstrate working of split(regex, 
// limit) with small limit. 
public class GFG { 
    public static void main(String args[]) 
    { 
        String str = "[email protected][email protected]"; 
        String[] arrOfStr = str.split("@", 2); 
  
        for (String a : arrOfStr) 
            System.out.println(a); 
    } 
}

Code Example 3

String yourString = "Hello/Test/World";
String[] strings = yourString.split("/" /*<- Regex */); 

Output:
strings = [Hello, Test, World]

Code Example 4

public class SplitExample2 { 
    public static void main(String args[]) 
    { 
        String str = "My name is Chaitanya";
        //regular expression is a whitespace here 
        String[] arr = str.split(" "); 
  
        for (String s : arr) 
            System.out.println(s); 
    } 
}

Learn ReactJs, React Native from akashmittal.com