課程
/后端開發(fā)
/Java
/Java入門第三季
我填寫完代碼后在eclipse中執(zhí)行,完全沒問題。但是在這里就是無法通過。好奇怪啊?。?!
2016-04-16
源自:Java入門第三季 3-8
正在回答
有時(shí)候會(huì)出現(xiàn)小小問題、看提示進(jìn)行敲代碼!
風(fēng)云7857 提問者
public class HelloWorld {?? ???? public static void main(String[] args) {?????? ???????? // 定義一個(gè)整型數(shù)組,長(zhǎng)度為10??????? int[] nums =new int[10];?????? ???????? //通過循環(huán)給數(shù)組賦值?? ??? ?for (int i = 0; i < nums.length; i++) {??????????? // 產(chǎn)生10以內(nèi)的隨機(jī)數(shù)?? ??? ??? ?int x = (int)(Math.random()*10);?????????? ??? ??? ??? ?nums[i] = x;// 為元素賦值?? ??? ?}?????? ??? ??? ?// 使用foreach循環(huán)輸出數(shù)組中的元素?? ??? ?for (int num:nums) {?? ??? ??? ?System.out.print(num + " ");?? ??? ?}?? ?}}public class HelloWorld {?? ???? public static void main(String[] args) {?????? ???????? // 定義一個(gè)整型數(shù)組,長(zhǎng)度為10??????? int[] nums =new int[10];?????? ???????? //通過循環(huán)給數(shù)組賦值?? ??? ?for (int i = 0; i < nums.length; i++) {??????????? // 產(chǎn)生10以內(nèi)的隨機(jī)數(shù)?? ??? ??? ?int x = (int)(Math.random()*10);?????????? ??? ??? ??? ?nums[i] = x;// 為元素賦值?? ??? ?}?????? ??? ??? ?// 使用foreach循環(huán)輸出數(shù)組中的元素?? ??? ?for (int num:nums) {?? ??? ??? ?System.out.print(num + " ");?? ??? ?}?? ?}}
舉報(bào)
Java中你必須懂得常用技能,不容錯(cuò)過的精彩,快來加入吧
2 回答代碼在eclipse中運(yùn)行沒問題,就是在慕課網(wǎng)這里的編譯不通過!
3 回答慕課這里是不是有問題啊?
2 回答誰有慕課網(wǎng)代碼編輯器配色方案
1 回答慕課網(wǎng)改版之后,怎么老是出現(xiàn)網(wǎng)絡(luò)不好的情況
2 回答這個(gè)編譯器怎么沒法用
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-05-25
有時(shí)候會(huì)出現(xiàn)小小問題、看提示進(jìn)行敲代碼!
2016-04-16
public class HelloWorld {
?? ?
??? public static void main(String[] args) {
?????? ?
??????? // 定義一個(gè)整型數(shù)組,長(zhǎng)度為10
??????? int[] nums =new int[10];
?????? ?
??????? //通過循環(huán)給數(shù)組賦值
?? ??? ?for (int i = 0; i < nums.length; i++) {
??????????? // 產(chǎn)生10以內(nèi)的隨機(jī)數(shù)
?? ??? ??? ?int x = (int)(Math.random()*10);
?????????? ?
?? ??? ??? ?nums[i] = x;// 為元素賦值
?? ??? ?}
?????? ?
?? ??? ?// 使用foreach循環(huán)輸出數(shù)組中的元素
?? ??? ?for (int num:nums) {
?? ??? ??? ?System.out.print(num + " ");
?? ??? ?}
?? ?}
}public class HelloWorld {
?? ?
??? public static void main(String[] args) {
?????? ?
??????? // 定義一個(gè)整型數(shù)組,長(zhǎng)度為10
??????? int[] nums =new int[10];
?????? ?
??????? //通過循環(huán)給數(shù)組賦值
?? ??? ?for (int i = 0; i < nums.length; i++) {
??????????? // 產(chǎn)生10以內(nèi)的隨機(jī)數(shù)
?? ??? ??? ?int x = (int)(Math.random()*10);
?????????? ?
?? ??? ??? ?nums[i] = x;// 為元素賦值
?? ??? ?}
?????? ?
?? ??? ?// 使用foreach循環(huán)輸出數(shù)組中的元素
?? ??? ?for (int num:nums) {
?? ??? ??? ?System.out.print(num + " ");
?? ??? ?}
?? ?}
}