after i put in the for loop, one of my exception handling stop working; how can i fix it
Code:
import javax.swing.*;
public class Testnum
{
public static void main(String []args)
{
char []upper = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char []lower = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
String []place= {"first","second","third","fourth","fithth","sixth","seventh","eighth","ninth","ten","Eleventh",
"Twelfth", "Thirteenth", "Fourteenth", "Fifteenth", "Sixteenth","Seventeenth", "eighteenth","ninteenth","twentieth","21st","22nd","23rd","24th","25th","26th"};
try{
String input = JOptionPane.showInputDialog("Enter a character or click 'Cancel' to end");
int length=input.length();
for(int j=0; j<length; j++){ [COLOR="DarkGreen"]//the cause[/COLOR]
char num=input.charAt(j);
if (Character.isLetter(num) )
for(int i =0; i<upper.length; i++)
{
if(Character.isUpperCase(num))
{
if(upper[i] ==num)
{
System.out.println(num+" is Upper case");
System.out.println(num +" is the "+(place[i]) +" in the alphabet");
}
}
else
{
if(lower[i] ==num)
{
System.out.println(num+" is Lower case");
System.out.println(num +" is the "+(place[i]) +" in the alphabet");
}
}
}
else if (Character.isDigit(num)){
System.out.println(num+ " is a number");
}
else{
System.out.println(num+ " is neither a number or a letter");
}
}
}
catch (NullPointerException aob){
System.out.print("Program ended");
System.exit(0);
}
catch (StringIndexOutOfBoundsException outof){ [COLOR="DarkGreen"]//This catch doesn't work[/COLOR]
System.out.print("No input letter: program will end");
System.exit(0);
}
}
}