Question: Why am I receiving a length of 3 instead of 4? How can I fix this to give the proper length?

```
String s="+9851452;;FERRARI;;";
String split[]=s.split("[;]");
System.out.println(split.length);

```

Answer: 
You're receiving a length of 3 because for [`split`](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)),

> 
> This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. **Trailing empty strings are therefore not included in the resulting array**.
> 
> 
> 

If you specify a negative limit, it'll work fine:

```
    String s="+9851452;;FERRARI;;";
    String split[]=s.split(";", -1);
    System.out.println(Arrays.toString(split));

```

You'll just need to ignore or remove the 5th item, or remove the trailing `;` - it shows up because there are 5 (potentially blank) strings on either sides of 4 tokens. See the [docs](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String,%20int)) for more info.
You can use StringUtils from apache commons lang.

```
String s="+9851452;;FERRARI;;";
Arrays.toString(StringUtils.splitPreserveAllTokens(s, ";"))

```