為什么不對啊?
public class HelloWorld{
??? public static void main(String[] args) {
??int score = 68;
??String mark = (score >= 60) ? "及格":"不及格" ;
??System.out.println("考試成績?nèi)绾危?+mark);
?}
}
public class HelloWorld{
??? public static void main(String[] args) {
??int score = 68;
??String mark = (score >= 60) ? "及格":"不及格" ;
??System.out.println("考試成績?nèi)绾危?+mark);
?}
}
2020-02-28
public class HelloWorld{
??? public static void main(String[] args) {
??int score = 68;
??String mark = ((score >= 60) ? "及格":"不及格") ;
??System.out.println("考試成績?nèi)绾危?+mark);
?}
}
沒加括號 ? 看看我給你修改后的.
你的 : 是全角符號,切成半角就好了
public class HelloWorld{
//是你的標(biāo)點(diǎn)符號的問題
? ? public static void main(String[] args) {
int score=68;
String mark =(score>60)?"及格":"不及格";
System.out.println("考試成績?nèi)绾危?+mark);
}
}
如果和答案一樣的話估計(jì)是標(biāo)點(diǎn)符號的問題
你看看及格與不及格之間的冒號對不對,你的好像是中文符號
舉報(bào)
2020-12-09
代碼沒錯(cuò),寫時(shí)注意是英文符號不是中文符號