Home » Java » A string of small practice

A string of small practice

Judge
// identifier, the identifier is by letter alphanumeric, letters and symbols which contains an underscore _, this definition contains the keyword.
/ / the specified string is in accordance with the judgment of cases of identifier syntax.
Class Identifier
{
Public static void main (String[] args)
{
String str= "_abckdj99$0d";
System.out.println ("STR is the identifier: +isIdentifier (STR));
}
Public static Boolean isIdentifier (String STR)
{
If (STR =null >0) and str.length (!)
{
Char ch=str.charAt (0);
If (ch>=' a' &&ch<=' z' ch>=' ||; A' &&ch<=' Z' ch==' ||; _' ||ch==' $')
{
For (int i{
Ch=str.charAt (I);
(if! (ch>=' a' z' ||ch>=' ch<=' A' Z' ||ch==' ch<=' -' ||ch==' $' ||ch>=' 0' ch<=' 9'))
{
Return false;
}
}
Return true;
}
}
Return false;
}
}

Latest