Array/ArrayList OutOfBoundsException
<pre><code>public static void getVegetableFromUser()
{
 String[] veg = SandwichDB.getVegetable();
    HashMap&lt;String, String&gt; getMapVegPrice = SandwichDB.getMapVegPrice();
    int vegSave = Validator.getInt(Scanner, "Select Vegetables [1, 8]: ", 1, 8);
    String v = veg[vegSave-1];
    sandwich.setVegetables(v);
}
</code></pre>

<p>Okay so the console prints out  </p>

<blockquote>
  <p>=== Select Sandwich Vegetables ===<br>
  1 red onions $0.10<br>
  2 olives $0.10<br>
  3 pickles $0.10<br>
  4 lettuce $0.20<br>
  5 green peppers $0.25<br>
  6 tomatoes $0.30<br>
  7 cheese $0.49<br>
  8 Quit Vegetable Section<br>
  Select Vegetables [1, 8]:  </p>
</blockquote>

<p>The idea is to be able to pick multiple vegetables until I pick 8 which is quit vegetable section. How would I get about doing that?  With an else-if statement?</p>

<p>Also, vegetables is supposed to be an array, not an string...like on this line: <code>String v = veg[vegSave-1]</code>.</p>

<p>Here's the code on my SandwichDB.app:</p>

<pre><code>public static String[] getVegetableInfo()
{
    ArrayList&lt;String&gt; vegsList = new ArrayList&lt;&gt;();

    try (BufferedReader in =
            new BufferedReader(
            new FileReader("vegetable.txt")))
    {
        String line = in.readLine();
        while (line != null)
        {
            String[] elems = line.split("~");
            vegsList.add(elems[0] + " $" + elems[1]);
            line = in.readLine();
        }
        vegsList.add("Quit Vegetable Section");
    }
    catch(IOException e)
    {
        System.out.println(e);
        return null;
    }
    String[] vegetableInfo = vegsList.toArray(new String[]{});
    return vegetableInfo;
}    
</code></pre>
