hi!
I have been trying to write a program, it should first read in a word with JOptionPane.showInput... and the if the word was the same if you read it from the beginning or behind forexample lol, mum and so on... I have written a code and it seems fine to me but when I run it in Netbeans it shows an error that the string index is out of range please help

!!
Michcio
public static void main(String [] arg){
String a = JOptionPane.showInputDialog("Skriv in ett ord!");
int b = 0;
int c = a.length();
String ord1 = "";
String ord2 = "";
for(int d=0; !(c==b); d++){
ord1 = ord1 + a.substring(b,(b+1));
ord2 = ord2 + a.substring(c,(c+1));
c--;
b++;
}
if(ord1.equals(ord2))
JOptionPane.showMessageDialog(null, "Det inskrivna ordet är ett palindrom!!!");
System.exit(0);
}
}
M.