NullPointerException encountered in my homworked about regex
<p>I'm writing the code below trying to accept multi-line Strings such as</p>

<pre><code>Item #&lt;tab&gt;Description&lt;tab&gt;unit price&lt;tab&gt;quantity
</code></pre>

<p>Or </p>

<pre><code>Item #&lt;tab&gt;Description&lt;tab&gt;unit price&lt;tab&gt;quantity&lt;tab&gt;tax rate
</code></pre>

<p>so I used split() try to split the string to lines and the split them into items. However, when I run my test, I encounterd NullPointerException. I cannot find error in my code. Could sb help me out? Thank you very much.</p>

<pre><code>import java.util.ArrayList;

public class Matcher {
    private  String format;
    private  String[] arrayLine;
    private  ArrayList&lt;String[]&gt; arrayTab;

    public Matcher(String format){
        this.format = format;
    }
    private String[] splitLines(){
        arrayLine = format.split("\n");
        return arrayLine;
    }
    private ArrayList&lt;String[]&gt; splitTabs(){
        arrayLine = splitLines();
        int i;
        String[] arrayItem;
        for(i=0; i &lt; arrayLine.length; i++){
            arrayItem = arrayLine[i].split("/t");
            arrayTab.add(arrayItem);
        }
        return arrayTab;
    }
    public ArrayList&lt;Double&gt; extractPrice(){
        arrayTab = splitTabs();
        double price;
        ArrayList&lt;Double&gt; priceList = new ArrayList&lt;Double&gt;();
        for(String[] line : arrayTab){
            price = Double.valueOf(line[2]);
            priceList.add(price);
        }
        return priceList;
    }
    public ArrayList&lt;Integer&gt; extractQuantity(){
        arrayTab = splitTabs();
        int number;
        ArrayList&lt;Integer&gt; quantityList = new ArrayList&lt;Integer&gt;();
        for(String[] line : arrayTab){
            number = Integer.valueOf(line[3]);
            quantityList.add(number);
        }
        return quantityList;
        }
    public ArrayList&lt;Double&gt; extractTax(){
        arrayTab = splitTabs();
        double tax;
        ArrayList&lt;Double&gt; taxList = new ArrayList&lt;Double&gt;();
        for(String[] line : arrayTab){
            if(line.length == 4){
                tax = Double.valueOf(line[4]);
                taxList.add(tax);
            }
            else{
                taxList.add((double) 0);
            }
        }
        return taxList;
        }
    }
</code></pre>
