title: Correctly implementing a try/catch statement with regards to integer ArrayLists
body: <p>I'm writing a Java application which allows the user to enter a number of integer values and insert them into an ArrayList. The user should be asked after each item is entered, whether to continue entering data or to exit the application.</p>
  
  <p>As well as that I have to enter a double value to see the type of exception thrown. Once identified, to write a Try/Catch statement which deals with the specific exception and allows the user to continue entering data (rather than having the application crash).</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.ArrayList;
  
  public class Tester{
    public static void main(String[] args){
    ArrayList&lt;Integer&gt; myArrayList = new ArrayList&lt;Integer&gt;();
    Scanner input = new Scanner(System.in);
    while (true) {
        System.out.println("please enter an integer: ");
        integer.add(input.next());
  </code></pre>
  
  <p>So far, I have creating the ArrayList and prompting the user for input done, now I'm having trouble with continuing to ask the user for input or asking them to stop the process (how do I do this?)</p>
  
  <p>Also how do I write the try/catch block part? I understand that the 'try' part must contain statements that may cause an exception. So how can I write something like:</p>
  
  <pre><code>try {
    if input = double
    System.out.print("This is an error")?
  }
  
  catch(inputMismatchexception e){
  ....
  }
  </code></pre>