第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何檢查具有特定索引的數(shù)組是否為空?

如何檢查具有特定索引的數(shù)組是否為空?

慕虎7371278 2021-05-11 16:26:30
我遵循了該線程中提出的要點(diǎn),但是出現(xiàn)錯(cuò)誤“對(duì)于參數(shù)類型,運(yùn)算符未定義[...]”我的代碼:public class Test{private int[] array = new int [5];  public int method(int i) {      for(int s = 0; s <= array.length; s++) {          if( array[s] != null) { //I get the error in here even though the highest upvoted answer in the linked question recommends this solution. I obviously cant check it for 0, because the user input can be 0.            array[s] = i;          } else {             method(i);        }      }   }}
查看完整描述

2 回答

?
繁星coding

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超4個(gè)贊

您將收到此錯(cuò)誤,因?yàn)?code>int它是原始類型。在您的情況下,array[s]返回int而不是Integer。Int不能是一個(gè)null。

從改變你的陣列int[]Integer[],如果你想查詢?yōu)榭铡?/p>

private Integer[] array = new Integer[5];


查看完整回答
反對(duì) 回復(fù) 2021-05-26
  • 2 回答
  • 0 關(guān)注
  • 154 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)