亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

b代表的是索引還是什么?

我這樣理解的,數組里面最后一個的索引是-1,所以讀到-1就結束了,可是不知道為什么又轉換成16進制了,b輸出來到底是什么內容?

正在回答

3 回答

int b;

while((b=in.read())!=-1){

}

這里定義的b 是in.read()讀到有值的話就是整數,并把值賦值給b,然后與-1做比較,不等于-1,說明還有值,可以繼續讀取,如果是-1,里面沒有值了,退出循環

1 回復 有任何疑惑可以回復我~

?/**

? ? ?* Reads a byte of data from this input stream. This method blocks

? ? ?* if no input is yet available.

? ? ?*

? ? ?* @return? ? ?the next byte of data, or <code>-1</code> if the end of the

? ? ?*? ? ? ? ? ? ?file is reached.

? ? ?* @exception? IOException? if an I/O error occurs.

? ? ?*/

? ? public int read() throws IOException {

? ? ? ? return read0();

? ? }

?說的很清楚,the next byte of data, or <code>-1</code> if the end of the

? ? ?*? ? ? ? ? ? ?file is reached.沒有值是-1,讀的是里面的數據,不是索引


0 回復 有任何疑惑可以回復我~

你可以去看看源碼,里面表示read方法的返回值,源碼里面有寫如果沒有結尾,輸出值就不為-1

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

b代表的是索引還是什么?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號