Compare two different size of string arraylist in Java
<p>I have two string arraylists with difference size. I need to compare these two arraylists and take output. But it gave an error as <code>"Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 6, Size: 6"</code>  . What are the changes I need to do for that error. My code is,</p>

<pre><code>import java.util.ArrayList;
import java.util.Arrays;

public class TestCompareArrays {

    public static void main(String[] args) {

    ArrayList&lt;String&gt; arr1 = new ArrayList&lt;String&gt;(Arrays.asList("a","b","c","d","e","f"));
    ArrayList&lt;String&gt; arr2=  new ArrayList&lt;String&gt;(Arrays.asList("b","d","f"));

            for(int i = 0; i &lt;= arr1.size(); i++){
                if(arr2.contains(arr1.get(i))){
                     System.out.println("yes");
                }
                     else{
                         System.out.println("No");
                     }}
}}
</code></pre>