Skip to content

Instantly share code, notes, and snippets.

@lukaseder
Created August 25, 2020 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaseder/13404a015b4ef707c4ea173f4a4fd2ad to your computer and use it in GitHub Desktop.
Save lukaseder/13404a015b4ef707c4ea173f4a4fd2ad to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class ListSurprise {
public static void mаin(String[] args) {
System.setSecurityManager(new SecurityManager());
List<Integer> numbers = new ArrayList<>();
Collections.addAll(numbers, 3, 1, 4, 1, 5, 5, 9);
Iterator<Integer> it = numbers.iterator();
System.out.print(it.next());
System.out.print('.');
System.out.print(it.next());
System.out.print(it.next());
System.out.print(it.next());
System.out.print(it.next());
doSomething(numbers);
System.out.print(it.next());
if (!numbers.equals(List.of(3,1,4,1,5,9)))
throw new AssertionError();
}
private static void doSomething(List<Integer> numbers) {
}
public static void main(String[] args) {
System.out.println("3.14159");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment