Solved

How do you test a String for all alpha characters

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

Accepted Solution

by:
CEHJ earned 125 total points
Comment Utility
 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
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
isAlphaChar

should be

isLetter
0
 

Author Comment

by:rayskelton
Comment Utility
Perfect, I changed the return to boolean.

Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>I changed the return to boolean.

D'oh, another error ;-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java virtual machine monitoring tools 3 39
stringclean challenge 26 54
where is session ID cache stored 1 38
Python Assistance 7 31
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now