Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How do you test a String for all alpha characters

Posted on 2003-10-23
Last Modified: 2010-05-18
How do you test a String for all alpha characters, or all numeric characters returning a bool?
Question by:rayskelton
  • 3
LVL 86

Accepted Solution

CEHJ earned 125 total points
ID: 9606184
 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;

LVL 86

Expert Comment

ID: 9606194

should be


Author Comment

ID: 9606520
Perfect, I changed the return to boolean.

LVL 86

Expert Comment

ID: 9608054
>>I changed the return to boolean.

D'oh, another error ;-)

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
throw exception 21 58
Glassfish admin console not working 1 34
Is Applet the way to go for my drag and drop system? 8 25
Bot application - advice 3 38
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question