/********************************************* If文 その4 文字の判定 *********************************************/ import java.util.*; public class If04CharCheck { public static void main(String[] args) { Scanner sc=new Scanner(System.in); char c; // 入力した文字 String keybd; System.out.print("1文字入力して下さい-->"); keybd=sc.nextLine(); c=keybd.charAt(0); if ( c>=0x41 && c<=0x5a ) System.out.print("\n大文字です\n"); else if ( c>=0x61 && c<=0x7a ) System.out.print("\n小文字です\n"); else if ( c>=0x30 && c<=0x39 ) System.out.print("\n数字です\n"); else System.out.print("\n英数字以外の文字です\n"); } }