Question: Error
-----

---

##

> 
> 
> ```
> --
> 
> ```
> 
> -- Database: `verticalned`
> --------------------------
> 
> 
> -- --------------------------------------------------------
> -----------------------------------------------------------
> 
> 
> -- Table structure for table `announcements`
> 
> 
> 

```
CREATE TABLE  `announcements` (
    `id` INT( 10 ) NOT NULL , 
    `description` VARCHAR( 6000 ) DEFAULT NULL  , 
    `links` VARCHAR( 100 ) DEFAULT NULL , 
    `first` TINYINT( 1 ) DEFAULT > NULL , 
    `second` TINYINT( 1 ) DEFAULT NULL , 
    `third` TINYINT( 1 ) DEFAULT NULL , 
    `fourth` TINYINT( 1 ) DEFAULT NULL , 
    `staff` VARCHAR( 22 ) DEFAULT NULL , 
    `time` DATETIME( 2 ) DEFAULT NULL , 
    `subject` VARCHAR( 100 ) DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;

```

> 
> MySQL said: Documentation
> 
> 
> 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
> =======================================================================================================================================
> 
> 
> near '(2) DEFAULT NULL, `subject` varchar(100) DEFAULT NULL )
>  ENGINE=InnoDB DEFAULT ' at line 20
> 
> 
> 

---

version
-------

---

---

[![enter image description here](https://i.stack.imgur.com/dJcLp.jpg)](https://i.stack.imgur.com/dJcLp.jpg)

Answer: 
[split(java.lang.String regex)](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)) calls [split(java.lang.String regex ,int limit)](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String,%20int)) with an argument of 0.

> 
> If n is zero then the pattern will be applied as many times as
>  possible, the array can have any length, and **trailing empty strings**
> **will be discarded**.
> 
> 
> 

You may call this method by yourself with a positive value (and large enough to be sure to include all tokens) to prevent empty tokens from being discarded :

```
String[] jsonElements = zeroIn.split("\\|", zeroIn.length());

```

**Note** : from the comments below, using a negative value is indeed a better way to do this :

```
String[] jsonElements = zeroIn.split("\\|", -1);

```

> 
> If n is non-positive then the pattern will be applied as many times as
>  possible and the array can have any length.
> 
> 
>
From `String` class and `split` method [doc](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#split-java.lang.String-):

> 
> Trailing empty strings are therefore not included in the resulting array. 
> 
> 
> 

So, after last occurrence of not empty string, rest will be not included in array.