I am trying to convert upper case letters to lower case and I get the following error:
animalException in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 6
at java.lang.String.charAt(Unknown Source)
at newproject.chars.main(chars.java:11)
Here is my code:
public class chars {
public static void main(String[] args) {
String a = "AnImAl";
for(int b=0;b<=a.length();b++) {
char c= a.charAt(b);
if(c>=65 && c<=90)
{
c=(char)((c + 32));
}
System.out.print(c);
}
}
}
Could somebody explain to me why I get this error? Thanks in advance