Difference between revisions of "Iterable Immutable List Assignment"
Jump to navigation
Jump to search
(→Test) |
|||
Line 1: | Line 1: | ||
− | =Code To | + | =Code To Revisit= |
+ | ==DefaultImmutableList== | ||
+ | [[ImmutableList_Assignment]] | ||
+ | |||
+ | =References= | ||
==Iterable== | ==Iterable== | ||
:[https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html interface java.lang.Iterable<T>] | :[https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html interface java.lang.Iterable<T>] | ||
Line 18: | Line 22: | ||
=Code To Implement= | =Code To Implement= | ||
==DefaultImmutableList== | ==DefaultImmutableList== | ||
− | {{JavaToImplement|DefaultImmutableList| | + | {{JavaToImplement|DefaultImmutableList|iterator|immutable.list.assignment}} |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===iterator=== | ===iterator=== | ||
<nowiki>public Iterator<E> iterator()</nowiki> | <nowiki>public Iterator<E> iterator()</nowiki> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=Example= | =Example= |
Revision as of 16:28, 24 April 2020
Contents
Code To Revisit
DefaultImmutableList
References
Iterable
Iterator
ImmutableList
public interface ImmutableList<E> extends Iterable<E> { E head(); ImmutableList<E> tail(); boolean isEmpty(); }
Code To Implement
DefaultImmutableList
class: | DefaultImmutableList.java | |
methods: | iterator | |
package: | immutable.list.assignment | |
source folder: | src/main/java |
iterator
public Iterator<E> iterator()
Example
class: | ListsExample.java | |
package: | immutable.list.example | |
source folder: | src/main/java |
The code:
ImmutableList<Integer> numbers = Lists.brackets(4, 66, 99); for (int i : numbers) { System.out.println(i); }
produces:
4 66 99
Test
class: | IterableAssignmentTestSuite.java | |
package: | immutable.list.assignment | |
source folder: | src/test/java |