title: How to solve Index 1 out of bounds for length 1
body: <p>I have a method <code>jsonProductItems()</code> which return a map with String key and value.</p>
  <pre><code>public Map&lt;String, String&gt; jsonProductItems() throws IOException {
          List&lt;String&gt; products = new ArrayList&lt;&gt;();
          Map&lt;String, String&gt; productsAndIdentifier = new LinkedHashMap&lt;&gt;();
          for (Item item : example.getItems()) {
              products.add(item.getName());
          }
          for (int i = 0; i &lt; products.size(); i++) {
              productsAndIdentifier.put(indetifier.get(i), products.get(i));
          }
          System.out.println();
          
          return productsAndIdentifier;
      }
  </code></pre>
  <p>When in the same class in other method  I want to do a matrix. When value from matrix is equal with a key from map returned by <code>jsonProductItems()</code> method, will print value of this key. But at line <code>if((&quot;&quot; + sumByRemainder.get(i) + j).equals(entry.getKey()))</code> have <code>java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1</code>. How to solve this problem? And why in this case it appear?</p>
  <pre><code>for (int i = 0; i &lt;= rows; i++) {
              System.out.print(sumByRemainder.get(i) + &quot; &quot;);
              for (int j = 1; j &lt;= columns; j++) {
  
                  if (i == 0) {
                      System.out.print(&quot; &quot; + j);
                      System.out.print(&quot; &quot;);
                  } else {
                      indetifier.add(&quot;&quot; + sumByRemainder.get(i) + j);
                      for (Map.Entry&lt;String, String&gt; entry : jsonProductItems().entrySet()) {
                          if((&quot;&quot; + sumByRemainder.get(i) + j).equals(entry.getKey())){
                              System.out.println(jsonProductItems().get(entry.getKey()));
                          }else{
                              System.out.print(&quot;&quot; + sumByRemainder.get(i) + j + &quot; &quot;);
                          }
                      }
  </code></pre>