假如你用StreamTokenizer的话,那里面有StreamTokenizer.ttype,可以判定是否是数字。 你也可以 Character.isDigit(char ch)来判定没一个字符是否是数字。 Character类的方法 static boolean isDigit(char ch) Determines if the specified character is a digit.
static boolean isLetter(char ch) Determines if the specified character is a letter.
static boolean isLetterOrDigit(char ch) Determines if the specified character is a letter or digit.
static boolean isWhitespace(char ch) Determines if the specified character is white space according to Java.
import java.io.*; public class test { public static void main(String[] args)throws IOException { int s[]=new int[10]; s[0]=System.in.read();//正确的应该改为s[0]=Integer.parseInt(args[0]); System.out.println(s[0]);