i am getting run time error as provided in title
my code is
class maxstring
{
public static void main(String args[])
{
String s1="nikhil is a good boy";
int d;int x=0;
d=s1.length();
String[] s2=new String[d];
char ch;
for(int i=0;i<=d-1;i++)
{
ch=s1.charAt(i);
if(ch==' ')
{
s2[x]=s1.substring(x,i-1);
x=i+1;
}
}
String max=s2[0];
for(int i=0;i<=d-1;i++)
{
if(s2[i].compareTo(max)>0)
max=new String(s2[i]);
}
System.out.println(max);
}
}