我写了这段代码来检查char是否是元音
package ifstatement;
public class IfStatement {
public static void main(String[] args) {
// TODO Auto-generated method stub
char ch='a';
if(ch==a||ch==e||ch==i||ch==o||ch==u) {
System.out.println("It is a Vowel.");
}
else {
System.out.pirntln("It is not a Vowel.");
}
}
}
但是我收到此错误:-
o cannot be resolved to a variable
u cannot be resolved to a variable
The method pirntln(String) is undefined for the type PrintStream
at ifstatement/ifstatement.IfStatement.main(IfStatement.java:8)
o
是名为o
]的变量>'o'
是字符o
"o"
是一个字母的字符串,o
您需要的是
是一个错字if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
并且pirntln
您可以通过以下任意一种方式进行: