I have two exact copies of code here, except one has '<' in the for loops while the other has '<='. Could someone please explain why I get the index out of bounds exception when I use '<=', but then it works fine with '<'

Error code:

```
for(int i = 0; i <= str.length(); i++) {
      int count = 0;
      char currentChar = str.charAt(i);
      for(int j = 0; j <= str.length(); j++) {
        if (currentChar == str.charAt(j) ) {
          count++;

```

Working code:

```
for(int i = 0; i < str.length(); i++) {
      int count = 0;
      char currentChar = str.charAt(i);
      for(int j = 0; j < str.length(); j++) {
        if (currentChar == str.charAt(j) ) {
          count++;

```

If I don't use <= how will it compare the last character in the string?