久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

實(shí)現(xiàn) Iterable 接口

Implementing the Iterable interface(實(shí)現(xiàn) Iterable 接口)
本文介紹了實(shí)現(xiàn) Iterable 接口的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我剛剛在一份舊試卷中發(fā)現(xiàn)了這個(gè)試題,并且正在為即將到來的考試做準(zhǔn)備.我想不通:

I just found this exam question in an old exam paper and am readying myself for an upcoming exam. I cannot figure it out :

下面描述了一個(gè)人為的部分類,它實(shí)現(xiàn)了 Iterable 接口.此類的唯一目的是提供一種方法來迭代屬性 things.

The following depicts a contrived partial class which implements the Iterable interface. The only purpose of this class is to provide a method to iterate over the attribute things.

我們需要在課堂上填寫兩件事來完成它.這里是類

There are two things we need to fill in in the class to finish it. Here is the class

private class PartialIterableClass /*FILL IN */ {
   private String[] things;
   public PartialIterableClass( String[] things ){
      this.things = things;
   }
   /*FILL IN 2*/
}

我猜它應(yīng)該類似于:

private class PartialIterableClass implements Iterable<PrivateIterableClass> {
   private String[] things;
   public PartialIterableClass( String[] things ){
      this.things = things;
   }
   public Iterator<PartialIterableClass> iterator( ){
   return new Iterator<PartialIterableClass>( ) {

   }
   }
}

不過,我不確定如何充實(shí)這個(gè)問題的答案,有人可以幫忙嗎?

I'm not really sure how to flesh out an answer to this question though, can anybody help?

推薦答案

你的 Iterator 必須實(shí)現(xiàn) Iterator 接口中的所有方法,才能封裝迭代邏輯.

Your Iterator must implement all the methods from the Iterator interface in order to encapsulate the iteration logic.

在您的情況下,它必須保存數(shù)組中的當(dāng)前迭代索引.您可以查看 ArrayIterator 來自 commons-collections

In your case, it will have to hold the current iteration index in the array. You can look at ArrayIterator from commons-collections

這篇關(guān)于實(shí)現(xiàn) Iterable 接口的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Java Remove Duplicates from an Array?(Java從數(shù)組中刪除重復(fù)項(xiàng)?)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復(fù)調(diào)用失敗來自服務(wù)器的意外響應(yīng):在 Android 工作室中未經(jīng)授權(quán))
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
AES Error: Given final block not properly padded(AES 錯(cuò)誤:給定的最終塊未正確填充)
Detecting incorrect key using AES/GCM in JAVA(在 JAVA 中使用 AES/GCM 檢測不正確的密鑰)
AES-256-CBC in Java(Java 中的 AES-256-CBC)
主站蜘蛛池模板: 精品国产青草久久久久福利 | 国产精品国产精品 | 国产亚洲一区二区精品 | 欧美一区 | 免费福利视频一区二区三区 | 欧美精品黄 | 九九热在线免费视频 | 欧洲尺码日本国产精品 | 毛片免费在线观看 | 成人福利影院 | 波多野结衣电影一区 | 亚洲国产精品一区 | 国产精品亚洲精品 | 国产精品久久久久aaaa九色 | 色眯眯视频在线观看 | 欧美日韩福利视频 | 人人玩人人添人人澡欧美 | 最新超碰 | 亚洲福利在线观看 | 日韩精品一区二区三区在线播放 | 国产毛片毛片 | 久久久久国产一区二区三区 | 毛片在线看片 | 成人欧美一区二区三区在线观看 | 99精品视频免费在线观看 | 人人澡人人射 | 成人免费高清 | 老牛影视av一区二区在线观看 | 中文字幕视频在线 | www.日韩 | 日韩精品一区二区三区免费视频 | 欧美一二区 | 久久99精品久久久水蜜桃 | 91视频进入 | 亚洲欧美另类在线观看 | 亚洲精品1区 | 中文字幕在线视频观看 | 国产精品污www在线观看 | 国产资源网 | 久久久久久久网 | 久久精品视频网站 |