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)