Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Character.isLetter() error on compile

843785Nov 5 2008 — edited Nov 6 2008
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2008
Added on Nov 5 2008
5 comments
1,298 views