步驟
A:導包
格式: import java.util.Scanner
B:創建鍵盤輸入對象
格式: Scanner sc = new.Scanner(System.in)
C:通過對象獲取數據
格式:int x = sc.nextInt()
代碼
import java.util.Scanner ;
class ScannerDome{
pubilc static void main (string[] args){
Scanner sc = new.Scanner(System.in);
int x = sc.nextInt();
System.out.println("x = " + x);
}
}