1. Determine if the string is only a numeric:1> with Java-brought function public static boolean isnumeric (string str) { for (Int i = str.length ();--i>=0;) { if (! Character.isdigit (Str.charat (i))) { return false; } } return true; }2> Regular Expression public static boolean isnumeric (STRING&NBSP;STR) { pattern pattern = pattern.compile ("[0-9]*"); Return pattern.matcher (str). Matches (); }3> with ASCII code public static Boolean isnumeric (STRING&NBSP;STR) { for (Int i=str.length ();--i>=0;) { int chr=str.charat (i); if (chr<48 | | chr>57) return false; } return true;} &Nbsp; 2. Determines whether the first character of a string is a letter public static boolean test ( String s) { char c = s.charat (0); int i = (int) c; if ((i>=65&&i<=90) | | (i>=97&&i<=122)) { return true; } else { Return false; } } public static boolean check (String Fstrdata) { &nbsP; char c = fstrdata.charat (0); if (((c>= ' a ' &&c<= ' Z ') | | (c>= ' A ' &&c<= ' Z ')) { return true; }else{ return & nbsp; false; } } &NBSP;&NBSP;3&NBSP: Judging Whether it is a Chinese character public boolean vd (STRING&NBSP;STR) { char[] chars=str.tochararray (); boolean isgb2312=false; for (int i=0;i<chars.length;i++) { byte[] bytes= ("" +chars[i]). GetBytes (); if (bytes.length==2) { int[] ints=new int[2]; ints[0]=bytes[0]& 0xff; ints[1]=bytes[1]& 0xff; if (Ints[0]>=0x81 && ints[0]<=0xfe && ints[1] >=0X40&NBSP;&&&NBSP;INTS[1]<=0XFE) { isGB2312=true; break; } } } return isgb2312; }
Java judging numbers or Chinese or letters