當前位置:首頁 » 編程語言 » java中關鍵字

java中關鍵字

發布時間: 2023-09-09 14:07:27

1. 在java中怎麼從鍵盤輸入一個數字 用什麼關鍵字

Scanner sc=new Scanner(System.in);

int j=sc.nextInt();

如果通過使用 nextInt() 方法,此掃描器輸入信息中的下一個標記可以解釋為默認基數中的一個 int 值。

關鍵字:一扮棚般是用scanner用法。

(1)java中關鍵字擴展閱讀

利用 Scanner 實現從鍵盤讀入integer或float 型數據:告缺州

importjava.util.*;

public class test {

public static void main(String args[])

{

Scanner in=new Scanner(System.in); //使用Scanner類定義對象

System.out.println("please input a float number");

float a=in.nextFloat(); //接收float型襪蔽數據

System.out.println(a);

System.out.println("please input a integer number");

int b=in.nextInt(); //接收整形數據

System.out.println(b);

}

}

熱點內容
綠源電動車威牛是什麼配置 發布:2025-03-11 08:47:34 瀏覽:8
wps加密文件密碼忘記 發布:2025-03-11 08:36:49 瀏覽:45
可編程渲染管線 發布:2025-03-11 08:35:23 瀏覽:453
一般人手機設置密碼會是什麼 發布:2025-03-11 08:27:19 瀏覽:414
緩存電視劇軟體 發布:2025-03-11 08:26:26 瀏覽:133
安卓怎麼下載ios14 發布:2025-03-11 08:25:50 瀏覽:565
軟體調試源碼 發布:2025-03-11 08:24:59 瀏覽:487
剪輯視頻怎麼配置解說 發布:2025-03-11 08:24:23 瀏覽:263
手機怎麼設數字密碼 發布:2025-03-11 08:22:50 瀏覽:74
學編程需要電腦嗎 發布:2025-03-11 08:22:43 瀏覽:20