GenuineSounds icon

Java Puzzler: Crossing Streams

GenuineSounds | PRO | 12/23/15 07:41:20 AM UTC | 0 ⭐ | 338 👁️ | Never ⏰ | []
Java |

1.01 KB

|

None

|

0 👍

/

0 👎

package com.genuinevm.puzzlers;
 
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
 
/**
 * This puzzler is called Crossing Streams, try and find out just by looking
 * what the code will print.
 * 
 * @author Brian Wiegand (GenuineSounds)
 */
public class CrossingStreams {
 
    public static List<String> STRINGS = Arrays.asList("Vadr", "Luke");
 
    public static void main(String[] args) {
        IntStream ints = IntStream.range(1, 4);
        STRINGS.stream().forEach(string -> {
            ints.forEach(integer -> {
                System.out.print(string + integer + ", ");
            });
            System.out.println();
        });
    }
}
/**
 * Multiple Choice
 * 
 * What will print:
 *   A) Vadr1, Vadr2, Vadr3,
 *      Luke1, Luke2, Luke3,
 *   B) Vadr1, Vadr2, Vadr3, Vadr4,
 *      Luke1, Luke2, Luke3, Luke4,
 *   C) Vadr1, Vadr2, Vadr3,
 *   D) Vadr1, Vadr2, Vadr3, Vadr4,
 *   E) Nothing
 *   F) None of the Above
 * 
 * Will it throw an exception?
 *   A) Yes
 *   B) No
 * 
 * Explain your answer.
 */

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎