How to solve java StringIndexOutOfBoundException

can any one help with the below code .

class demoStr
{

public void bigword()
{
	
	String str="animal";
	for(int i=0;i<str.length();i++)
	{
		 String s1=str.substring(i,i+1);
		 System.out.println("substring is:"+s1);
		
		 for(int j=0;j<str.length();j++)
		 {
			 if(s1.charAt(i)>(str.charAt(j))
				 
				 {
					 System.out.println(s1.charAt(i)+"is greater");
					 
				 }
				 
		 }

}

}
public static void main(String[] args)
{
	demoStr d1=new demoStr();
	d1.bigword();

why am i getting this error:
Exception in thread “main” java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.charAt(Unknown Source)
at demoStr.bigword(demoStr.java:15)
at demoStr.main(demoStr.java:35)

It should be telling you a line number where the error is happening. “index out of bounds” means that you are trying to reference something by an invalid index.
For example if your string was “Hi”, index 2 would be out of bounds.