I would recommend you use a couple of regex functions to test this. That would probably be the easiest way of doing it:
String numbers = "0123456789";
String letters = "abcde";
String rubbish="$%^&£\"";
Pattern numberPattern = Pattern.compile("^[0-9]+$");
Pattern letterPattern = Pattern.compile("^[a-zA-Z]+$");
System.out.print("Numbers should match number pattern: ");
System.out.println(numberPattern.matcher(numbers).matches());
System.out.print("Numbers should not match letter pattern: ");
System.out.println(letterPattern.matcher(numbers).matches());
System.out.print("Letters should match letter pattern: ");
System.out.println(letterPattern.matcher(letters).matches());
System.out.print("Letters should not match number pattern: ");
System.out.println(numberPattern.matcher(letters).matches());
System.out.print("Rubbish should not match number pattern: ");
System.out.println(numberPattern.matcher(rubbish).matches());
System.out.print("Rubbish should not match letter pattern: ");
System.out.println(letterPattern.matcher(rubbish).matches());
I would recommend making the Patterns private static final in your class so they are only compiled once this will make it pretty efficient.
Hope that helps,
Shane.