鍵盤錄入兩個整數判斷他們是否相等: 結果: ...
鍵盤錄入兩個整數判斷他們是否相等:
import java.util.Scanner; class Hello2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("請輸入第一個整數"); int x = sc.nextInt(); System.out.println("請輸入第二個整數"); int y = sc.nextInt(); boolean c = isEquals(x,y); System.out.println(c); } public static boolean isEquals(int a,int b) { return a==b; } }
結果: