Where are you "getting" it? The exception provides a line number, you know.
Also, why do
for(int i=0;i<=d-1;i++) when you can do
for(int i=0;i<d;i++).
I believe, however, that you problem is here
String[] s2=new String[d];
Doing that creates an array of reference variables that
must point to a String, however, initially all the elements contain a null pointer. You need to make sure that every element actually contains a reference to a String or the line
if(s2[i].compareTo(max)>0) will cause an NPE on any element where you have not explicitly initiated a String reference.
You can probably solve it by changing ....
Edit:
Scratch that, I'm not sure
what you're trying to do with that "logic" so I'll simply second that "add a null check".