提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
如何使用if else if语句比较两个数字。
public class Main { /* *来 自 时 代 J a v a - N o w J a v a . c o m */ public static void main(String[] args) { //declare two numbers to compare int num1 = 324; int num2 = 234; if(num1 > num2){ System.out.println(num1 + " is greater than " + num2); } else if(num1 < num2){ System.out.println(num1 + " is less than " + num2); } /** 来 自 时 代 J a v a - nowjava.com **/