title: How do I apply an if statement condition to every element on an arraylist?
body: <p>Basically I want to know how to apply an if condition to every element of an arraylist.
      Here's my code. </p>
  
  <pre><code>   System.out.println("Type positive integers less than 40: ");
  
      ArrayList&lt;Integer&gt; inRay = new ArrayList&lt;Integer&gt;();
      Scanner sc = new Scanner(System.in);
      while (sc.hasNext())
      {
          inRay.add(sc.nextInt());
      }
  
      //this is where the problem starts//
  
      int i;
      if (inRay.get(i) &gt; 40)
      {
          System.out.println("You had one job.");
          System.exit(0);
      }
  </code></pre>
  
  <p>I would like to apply an if condition where if a value in the array list is over 40, it exits.</p>