提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
基本的if else语句
class IfElseDemo { public static void main(String[] args) {/*来 自 时代Java - nowjava.com*/ int testscore = 76; char grade; if (testscore >= 90) { grade = 'A'; } else if (testscore >= 80) { grade = 'B'; } else if (testscore >= 70) { grade = 'C'; } else if (testscore >= 60) { grade = 'D'; } else { grade = 'F'; }// 来自 n o w j a v a . c o m System.out.println("Grade = " + grade); } }