The above code doesn't work since we can't use char data on compareto!!!!!!!!!!!

Here is the final version




Code:
class abecedarian
{
public static  void main(String args[])
{
System.out.println(test("agnosy"));
}
public static boolean test(String s)
{
int x=s.length();
int i=0;
int j=1;
int k=2;
while (k<=x)
{
String a=s.substring(i,j);
String b=s.substring(j,k);
int flag=a.compareTo(b);
if(flag<=0)
{
i++;
j++;
k++;
}
else
{
return false ;
}
}
return true;
}
}