Hi all. I'm trying to write a method that does a series of validations on the characters in a String. Here's my code:
import java.util.*;
import java.lang.*;
public class ScratchPad
{
public static void main(String args[])
{
Scanner kb = new Scanner(System.in);
System.out.println("Enter PN expression: ");
String myPN = kb.nextLine();
int isValid = validate(myPN, 3);
System.out.println("Came up as: " + isValid);
}
public static int validate(String expression, int vVar)
{
for (int x = 0; x < expression.length(); x++)
{
Character currChar = new Character(expression.charAt(x));
if (!currChar.isLetter()) //test to see if the Character is a letter, first error
return 1;
else if (currChar.isUpperCase()) //test to see if it's uppercase, second error
{ String operands = "NKAJEDC";
int intStr = operands.indexOf(currChar);
if (intStr < 0)
return 2;
}
}
return 0;
}//end validate
}
And here's my errors:
ScratchPad.java:24: cannot find symbol
symbol : method isLetter()
location: class java.lang.Character
if (!currChar.isLetter())
^
ScratchPad.java:26: cannot find symbol
symbol : method isUpperCase()
location: class java.lang.Character
else if (currChar.isUpperCase())
^
2 errors
The test I'm trying to make is supposed to see if the characters are alphabetic. There's also a limited number of capital letters allowed, hence the crazy String and indexOf. This was originally choking because I had a regular char instead of a Character variable, but when I fixed that I hit this one instead. Could someone please take a peek and let me know if/what I'm using incorrectly?
Thanks!
Kate