/**接收用户输入的一个字符并判断其是字母还是数字,
* 或者是其它字符,判断后输出相应的判定结果
**/
import java.io.*;
public class FirstProgram
{
public static void main(String[] args)
{
char c = ‘ ‘;
System.out.print("Enter a character please: ");
try
{
c = (char)System.in.read();
}
catch (IOException e)
{
};
if (c >= ‘A‘ && c <= ‘z‘ || c >= ‘a‘ && c <= ‘z‘)
System.out.println("You‘ve entered character "+ c);
else if (c >= ‘0‘ && c <= ‘9‘)
System.out.println("You‘ve entered integer "+ c);
else
System.out.println("You‘ve entered others "+ c);
}
}本文出自 “hacker” 博客,请务必保留此出处http://anglecode.blog.51cto.com/5628271/1619834
原文:http://anglecode.blog.51cto.com/5628271/1619834