[英]How to make program can get the value of a special character that inputted by the user
so i want to make a program that can read special character and change it into other character using caesar chiper.所以我想制作一个可以读取特殊字符并使用凯撒芯片将其更改为其他字符的程序。 but, i don't understand how actually a special character can be read in java.
但是,我不明白在 Java 中实际上如何读取特殊字符。 please teach me.
请教我。 thank you.
谢谢你。
Look at the Character class.查看 Character 类。 https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html
https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html
char[] charArray = {'1', ' ', '!', 'a', 'C'};
for (int i = 0; i < charArray.length; i++) {
char c = charArray[i];
if(Character.isWhitespace(c)) {
System.out.println( "'" + c +"'" + " is whitespace");
} else if (Character.isDigit(c)) {
System.out.println( "'" + c +"'" + " is a number");
} else if (Character.isLetter(c)) {
System.out.println( "'" + c +"'" + " is a letter");
} else {
System.out.println( "'" + c +"'" + " must be a special character");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.