title: How to find multiples of 3 and 5 in an array java
body: <p>I'm trying to write a code that finds the multiples of 3 and 5 in an array of numbers 1 to 100, the code I have generates the numbers I want but it gives me the multiples of 3, then gives me the multiples of 5 (Example: 3 6 9 12 15,5 10 15) I want them all together (Example 3 5 6 9 10 12 15).</p>
  
  <p>here is the code I have so far</p>
  
  <pre><code>for(int i = 0 ; i &lt; 100; i=i+3){
        if(i%3 == 0)
         System.out.println(i);
         }
      for (int i=1; i &lt; 100; i++) {
              if (i%5==0) System.out.println(i);}
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>if(i%3 == 0 &amp;&amp; i%5==0)
  </code></pre>
  
  <p>but that only gave me the numbers divisible by both</p>
  
  <p>an explanation after would be helpful thank you</p>