re: Daily Challenge #17 - Double Trouble VIEW POST

FULL DISCUSSION
 

My entry, written in Java:


    protected static void doubleTrouble() {

        List<String> people = new ArrayList<>();
        people.add("Sheldon");
        people.add("Leonard");
        people.add("Penny");
        people.add("Rajesh");
        people.add("Howard");


        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            String first = people.iterator().next();
            String person = people.get(people.indexOf(first));
            people.add(person);
            people.add(person);
            people.remove(first);

        }

        System.out.println(people.get(people.size() - 1));
    }

code of conduct - report abuse