• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

How do you test a String for all alpha characters

How do you test a String for all alpha characters, or all numeric characters returning a bool?
0
rayskelton
Asked:
rayskelton
  • 3
1 Solution
 
CEHJCommented:
 public static String allAlpha(String s) {
      StringBuffer sb = new StringBuffer(s);
      for(int i = 0;i < sb.length();i++) {
        if(Character.isAlphaChar(sb.charAt(i)) == false)
            return false;
      }
      return true;
  }

0
 
CEHJCommented:
isAlphaChar

should be

isLetter
0
 
rayskeltonAuthor Commented:
Perfect, I changed the return to boolean.

Thanks
0
 
CEHJCommented:
>>I changed the return to boolean.

D'oh, another error ;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now