Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Get Iterator metoda

[es] :: Java :: Get Iterator metoda

[ Pregleda: 2041 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

sivan347
.NET Programer
Beograd

Član broj: 84406
Poruke: 101
*.fiberop.matgnet.com.



Profil

icon Get Iterator metoda02.02.2007. u 10:21 - pre 209 meseci
Pozdrav svima,
Evo moj problem koji ne mogu da nadjem na Internetu vec danima:
napisao sam klasu koja reprezentuje kolekciju baziranu na nizu, a koja poštuje sledeći interface:
public interface Call {

public void add(Object obj);
public Object get(int index);
public void remove(Object obj);
public Object remove(int index);
public void update(int index, Object obj);
public void empty();
public int size();

}
bez koriscenja List, ArrayList ili Collection interface i to radi npr.

public class ProbaInterfejsa implements Call {
private Object[] alMemebers;
private Object[] alTemp;
private int iCurrentIndex = 0;
/** Creates a new instance of ProbaInterfejsa */
public ProbaInterfejsa() {
iCurrentIndex = 0;
alMemebers = new Object[iCurrentIndex];
}
public void add(Object obj)
{
alTemp = new Object[alMemebers.length+1];
alTemp = alMemebers.clone();

alTemp[alTemp.length - 1] = new Object();
alTemp[alTemp.length - 1] = obj;
alMemebers = new Object[alTemp.length];
alMemebers = alTemp.clone();
//alMemebers.add(obj);
}

public Object get(int index)
{
return alMemebers[index];
}
itd....
Sad bih trebao sledece:
obezbediti da kolekcija ima metodu getIterator koji vraća iterator koji ima implementiran interface Iterator. Ovo nemogu nigde da pronadjem a da ne koristim prethodno spomenute interface.
Bio bih vam zahvalan ako bi neko mogao da mi pomogne
Hvala.
 
Odgovor na temu

sivan347
.NET Programer
Beograd

Član broj: 84406
Poruke: 101
*.fiberop.matgnet.com.



Profil

icon Re: Get Iterator metoda02.02.2007. u 12:47 - pre 209 meseci
snasao sam se . Resenje je da se ubaci podklasa koja nasledjuje Iterator da bi u superklasi imali objekat Iterator
Pozdrav
 
Odgovor na temu

[es] :: Java :: Get Iterator metoda

[ Pregleda: 2041 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.