The pipe symbol is special in a regexp (it marks alternatives), you need to escape it. Depending on the java version you are using this could well explain your unpredictable results.

class t {
    public static void main(String[]_)
    {
        String temp = "0|0";
        String[] splitString = temp.split("\\|");

        for (int i=0; i<splitString.length; i++)
            System.out.println("splitString["+i+"] is " + splitString[i]);
    }       
}

outputs

splitString[0] is 0
splitString[1] is 0

Note that one backslash is the regexp escape character, but because a backslash is also the escape character in java source you need two of them to push the backslash into the regexp.

Answer from crazyscot on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ split-string-java-examples
Java String split() Method - GeeksforGeeks
December 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.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ split-a-string-in-java-with-delimiter
How to Split a String in Java with Delimiter? - GeeksforGeeks
July 23, 2025 - In Java, the split() method of the String class is used to split a string into an array of substrings based on a specified delimiter.
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ java โ€บ strings โ€บ .split()
Java | Strings | .split() | Codecademy
March 30, 2022 - Splits a string into an array of substrings based on a delimiter pattern.
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ java-how-to-split-a-string-into-an-arraylist-using-a-delimiter-in-java-415655
How to split a string into an ArrayList using a delimiter in Java | LabEx
Java provides a built-in method called split() in the String class that allows us to divide a string into parts based on a delimiter. The method returns an array of strings containing the substrings divided by the delimiter.
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ string โ€บ java string split() : splitting by one or multiple delimiters
Java String split() : Splitting by One or Multiple Delimiters
October 12, 2023 - It returns an array of split strings after the method splits the given string around matches. For using the multiple delimiters, the regular expression should define a character class that includes all the delimiters we want to split by.
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_string_split.asp
Java String split() Method
String myStr = "Split a string ... myArray) { System.out.println(s); } ... The split() method splits a string into an array of substrings using a regular expression as the separator....
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java string โ€บ java string.split()
Java.String.split() | Baeldung
March 12, 2025 - The split() method handles cases with leading delimiters by creating empty strings (โ€œโ€) in the resulting array. However, trailing delimiters are ignored unless we explicitly specify a limit of -1.
Find elsewhere
๐ŸŒ
Guru99
guru99.com โ€บ home โ€บ java tutorials โ€บ split() string method in java: how to split string with example
Split() String Method in Java: How to Split String with Example
December 26, 2023 - In this Java split string by delimiter case, the separator is a comma (,) and the result of the Java split string by comma operation will give you an array split.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ java โ€บ how to split string to array in java
How to Split String to Array in Java | Delft Stack
March 11, 2025 - One of the most straightforward ways to split a string into an array in Java is by using the built-in split() method from the String class. This method takes a regular expression as an argument and divides the string into substrings based on ...
๐ŸŒ
YouTube
youtube.com โ€บ oggi ai - artificial intelligence today
Java: Split String at Delimiter | break String into Array of Substrings - YouTube
This video explains how to split a string in Java into an array of substrings, at one or more delimiter characters such as space, period, or comma. Code: htt...
Published ย  April 20, 2023
Views ย  1K
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ standard-library โ€บ java โ€บ lang โ€บ String โ€บ split
Java String split() - Split String | Vultr Docs
December 17, 2024 - The split() method in Java is immensely beneficial for breaking up strings into arrays based on specified delimiters. It facilitates data manipulation, especially in scenarios involving structured text files like CSVs.
๐ŸŒ
Medium
medium.com โ€บ @AlexanderObregon โ€บ javas-string-split-method-explained-77bdaddaae79
Javaโ€™s String split() Method Explained
June 25, 2024 - In this example, the string "Hello world from Java" is split into an array of substrings using the space " " as the delimiter. The output will be: ... The split() method can also handle more complex delimiters by using regular expressions.
๐ŸŒ
Java Code Geeks
javacodegeeks.com โ€บ home โ€บ core java
How to Split a String into an Int Array in Java - Java Code Geeks
November 10, 2025 - A regular need is converting a ... way to convert a delimited string into an integer array in Java is by combining the split() method with Integer.parseInt()....
๐ŸŒ
Briebug Blog
blog.briebug.com โ€บ blog โ€บ java-split-string
Using the Java String.split() Method
Notice, it pulls the first string before the delimiter and puts it in the first element of the array. Because the limit is 2, the rest of the string is placed into the second element, with the delimiter still in the string.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ string-to-array-in-java-how-to-convert-a-string-to-an-array-in-java
String to Array in Java โ€“ How to Convert Strings to Arrays
July 6, 2023 - The split() method in Java is a convenient way to split a string into an array of substrings based on a specified delimiter.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ how-to-split-a-string-in-java
How to Split a String in Java
September 20, 2023 - Beyond this, the rest of the string will be returned as the last element of the array, as it is, without splitting. The length of the returned array will always be less than or equal to limit. A negative limit - The String is split at the delimiter as many times as possible, ignoring the particular negative value set.