課程
/后端開發
/Java
/Java入門第一季(IDEA工具)升級版
怎樣用鍵盤輸入為一個數組賦值和輸出?怎樣用數組去儲存商品的名稱和單價?
2017-05-05
源自:Java入門第一季(IDEA工具)升級版 7-1
正在回答
import java.util.Scanner;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? int[] scores = new int[3];?
Scanner s = new Scanner(System.in);
System.out.println("請輸入數組元素:");
? ? for(int i=0;i<scores.length;i++){
? ? ? scores[i] = s.nextInt();
? ? }
? ? System.out.println("你輸入的數組元素是:");
? ? System.out.println(scores[i]);
? ? }?
}
舉報
0基礎萌新入門第一課,從Java環境搭建、工具使用、基礎語法開始
3 回答將商品的單價存入數組中
1 回答可以用數組儲存對象嗎?
5 回答數組存不進去
1 回答char存儲的單個字符
1 回答數組不聲明個數默認是存儲多少個?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-05-05
import java.util.Scanner;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? int[] scores = new int[3];?
Scanner s = new Scanner(System.in);
System.out.println("請輸入數組元素:");
? ? for(int i=0;i<scores.length;i++){
? ? ? scores[i] = s.nextInt();
? ? }
? ? System.out.println("你輸入的數組元素是:");
? ? for(int i=0;i<scores.length;i++){
? ? System.out.println(scores[i]);
? ? }
? ? }?
}