(String[] args)
| 32 | |
| 33 | public class AdapterMethodIdiom { |
| 34 | public static void main(String[] args) { |
| 35 | ReversibleArrayList<String> ral = |
| 36 | new ReversibleArrayList<>( |
| 37 | Arrays.asList("To be or not to be".split(" "))); |
| 38 | // Grabs the ordinary iterator via iterator(): |
| 39 | for(String s : ral) |
| 40 | System.out.print(s + " "); |
| 41 | System.out.println(); |
| 42 | // Hand it the Iterable of your choice |
| 43 | for(String s : ral.reversed()) |
| 44 | System.out.print(s + " "); |
| 45 | } |
| 46 | } |
| 47 | /* Output: |
| 48 | To be or not to be |