title: How to display even number and a multiple of 3 from arraylist
body: <p>Sorry, maybe I did not explain clearly. This is my pracitce</p>
  
  <blockquote>
    <p>input a positive integer. If the input is not positive then then your algorithm should output an error message and re-prompt the user for the input. This process should continue to loop until the input is valid. Your algorithm should then output whether or not the input is an even number and a multiple of 3. Note your solution must make appropriate use of sub modules.</p>
  </blockquote>
  
  <p>I have to create a method which gets a positive number from user input, And I need to display even numbers and multiple of 3 from this ArrayList. I have written code for that but I have struggled with how to use another submodule to display this ArrayList.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.*;
  
  public class Array {
  
      public static void main(String[] args) 
      {
  
          Scanner sc = new Scanner(System.in);
          ArrayList&lt;Integer&gt; list;
          list = new ArrayList&lt;Integer&gt;();
           int number = -1;
          printList(list, number );
          System.out.println("Enter number.  Enter 0 to end.");
          while (true) 
          {
              System.out.print(" ");
              number = sc.nextInt();
  
          while( number &lt; 0)
          {
          System.out.print("Enter your next positive integer, or 0 to end: ");
          number = sc.nextInt();    
          }
           if (number == 0)
                  break;
              list.add(number);            
          }     
  
      }
          public static void printList (ArrayList&lt;Integer&gt; list, int number)
          {
              for(int i = 0;i &lt;= number.size(); i++)
              {
              if(i % 2 ==0 &amp;&amp; i % 3 ==0)
              {
                   System.out.println(list(i));
              }
              }
          }
      }
  </code></pre>