重要:利用ASCII码判断字母是否是大小写
需要引用 Scanner方法
代码:import java.util.Scanner;
1、利用char数组转化的优点在于面对字符串,也可以批量对单个字符操作
Scanner get_letter = new Scanner(System.in);String getLetter = get_letter.next();
char ss[] = getLetter.toCharArray();
if(ss[0]>96){System.out.println((char)(ss[0]-32));}else {System.out.println(getLetter);} 2、仅对单个操作 Scanner s = new Scanner(System.in);
String str = s.next();
char c = str.charAt(0);
if (c>96&&c<128){c = (char)(c-32);}
System.out.println(c); 标签:输出,Java,Scanner,getLetter,System,大写,char,out From: https://www.cnblogs.com/Lee597/p/17603637.html