English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

for example, could I say

if ( a != (A-Z) || a != (a- z) || a!=(0-9) )

?

is it possible? or how could it be done? thanks!

2006-11-17 07:04:40 · 3 answers · asked by MSM 1 in Computers & Internet Programming & Design

I forgot the single quotes around the characters. But the question is the same.

2006-11-17 07:05:28 · update #1

3 answers

Create your set like this:

HashSet mySet = new HashSet();
//add the chars that you want to consider
mySet.add( new Character( 'd' ) );
mySet.add( new Character( 'e' ) );

// and test
if ( mySet.contains( new Char( testChar ) )
{
do something.
}

you can try also by

if ( testChar < 'a' && testChar > 'z' )
{

}

2006-11-17 08:36:52 · answer #1 · answered by F.G. 5 · 0 0

i think there is two ways of doing this depending on the version of java you are useing:

1st:
public boolean valid(char c) {
int x = (int)c; // ascii value of c
return ((x >= 48 && x <= 57) || (x >= 65 && x <= 90) || (x >= 97 && x <= 122));
}

this will compare your char to ascii alphanumeric characters.

2nd:
use a regex learn here at sun
http://java.sun.com/docs/books/tutorial/essential/regex/intro.html

2006-11-17 07:15:44 · answer #2 · answered by Nick H 3 · 0 0

ContentsEditing Entire Arrays ... %LEN Used for its Value · %LEN Used to Set the Length of Variable-Length Fields. |%LOOKUPxx (Look Up an Array Element) ...
publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c092508302.htm - 69k - Cached - Similar pages

WebSphere Development Studio: ILE RPG Language Reference - Contents%CHAR (Convert to Character Data) · %CHECK (Check Characters) ... %LEN Used for its Value · %LEN Used to Set the Length of Variable-Length Fields ...
publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/books_web/c092508602.htm - 72k - Cached - Similar pages

Requirements for Writing Java API SpecificationsThe Java Compatibility Kit includes a test to verify each assertion, ... is composed of those specifications that apply to the entire set of packages. ...
java.sun.com/j2se/javadoc/writingapispecs/index.html - 42k - Cached - Similar pages

2006-11-17 07:08:56 · answer #3 · answered by god knows and sees else Yahoo 6 · 0 1

fedest.com, questions and answers