Open links in new tab
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. The split() method in Java is used to divide a string into an array of substrings based on a given regular expression (regex). It’s commonly used for parsing and processing text data efficiently.

    Example: Splitting by space

    public class Main {
    public static void main(String[] args) {
    String text = "Java is fun";
    String[] words = text.split(" ");
    for (String word : words) {
    System.out.println(word);
    }
    }
    }
    Copied!

    Output:

    Java
    is
    fun
    Copied!

    Basic Syntax

    public String[] split(String regex)
    public String[] split(String regex, int limit)
    Copied!
    • regex – The delimiter pattern (can be a string or regex).

    • limit – Controls the number of resulting substrings.

    Using split() without limit Splits at every match of the regex.

    String s = "a::b::c::d";
    String[] parts = s.split("::");
    System.out.println(Arrays.toString(parts));
    // Output: [a, b, c, d]
    Copied!

    Using split() with limit

    • limit > 0 → Splits at most limit - 1 times.

    • limit = 0 → Splits fully, removes trailing empty strings.

    • limit < 0 → Splits fully, keeps trailing empty strings.

    Feedback
  2. Java String split () Method - GeeksforGeeks

    Dec 20, 2025 · split () method in Java is used to divide a string into an array of substrings based on a specified delimiter or regular expression. The result of the …

  3. Java String.split () - Baeldung

    Mar 13, 2025 · In this article, we explored the String.split () method, which allows us to divide strings into smaller substrings based on specified delimiters. We learned how to use this method with regular …

  4. Java split string to array - Stack Overflow

    Jan 19, 2013 · This method works as if by invoking the two-argument split (java.lang.String,int) method with the given expression and a limit argument of zero. Trailing empty strings are therefore not …

  5. Java String split () - Programiz

    The Java String split () method divides the string at the specified separator and returns an array of substrings. In this tutorial, you will learn about the Java split () method with the help of examples.

  6. Mastering Java String `.split()` Method - javaspring.net

    Mar 27, 2026 · The split() method in the String class provides a convenient way to split a string into an array of substrings based on a specified delimiter. This blog post will take you through the …

  7. Convert String to Array in Java Using `split` — javathinking.com

    Jan 16, 2026 · In this blog post, we will explore the core concepts, typical usage scenarios, common pitfalls, and best practices related to using the split method for converting strings to arrays in Java.

  8. Java String split() : Splitting by One or Multiple Delimiters

    Oct 12, 2023 · Java String split () returns an array after splitting the string using the delimiter or multiple delimiters such as common or whitespace.

  9. Java String split () Method

    The String.split() method in Java is used to split a string into an array of substrings based on a specified delimiter. This guide will cover the method's usage, explain how it works, and provide examples to …

  10. String (Java Platform SE 8 ) - Oracle Help Center

    Constructs a new String by decoding the specified subarray of bytes using the specified charset.