Is it possible that Java String.split can return a null String[]

It never returns null. You should always check the javadoc of the method if you are not sure. For example String#split(String) says

This method works as if by invoking the two-argument split method

…and String#split(String,int) says:

If the expression does not match any part of the input then the resulting array has just one element, namely this string.

From Javadoc you can also find out what kind of exceptions can happen and more importantly why were those exceptions thrown. Also one very important thing to check is if the classes are thread safe or not.

Leave a Comment