1. Iterator Declaration



Yüklə 56 Kb.
səhifə1/3
tarix22.07.2023
ölçüsü56 Kb.
#137103
  1   2   3

1. Iterator 

  • Declaration 

public interface Iterator

Type Parameters:
E - the type of elements returned by this iterator

  • Iterators are used in Collection framework in Java to retrieve elements one by one. 

  • Method Summary 

Modifier and Type

Method

Description

default void

forEachRemaining(Consumer action)

Performs the given action for each remaining element until all elements have been processed or the action throws an exception.

boolean

hasNext()

Returns true if the iteration has more elements.

E

next()

Returns the next element in the iteration.

default void

remove()

Removes from the underlying collection the last element returned by this iterator (optional operation).

2. Collection 

  • Declaration: 

public interface Collection extends Iterable

Type Parameters:
E - the type of elements returned by this iterator

  • A Collection is a group of individual objects represented as a single unit. Java provides Collection Framework which defines several classes and interfaces to represent a group of objects as a single unit. 

  • Method Summary 


Yüklə 56 Kb.

Dostları ilə paylaş:
  1   2   3




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin