Java - Streams

From My Limbic Wiki

Collections

Main Methods

<source lang="Java"> add(Object o)

Adds the specified object to the collection.

remove(Object o)

Removes the specified object from the collection.

clear()

Removes all elements from the collection.

size()

Returns an integer that indicates how many elements are currently in the collection.

iterator()

Returns an object that can be used to retrieve references to the elements in the collection.

</source>

Sample

<source lang="Java"> Student student; Iterator iterator = collection.iterator(); while (iterator.hasNext()) {

   student = (Student)(iterator.next());
   System.out.println(student.getFullName());

} </source>

A voir

  • Parallel stream