Skip to content

Instantly share code, notes, and snippets.

@stephanos
Created October 28, 2012 08:40
Show Gist options
  • Save stephanos/3968077 to your computer and use it in GitHub Desktop.
Save stephanos/3968077 to your computer and use it in GitHub Desktop.
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
List<Integer> oddNumbers = new ArrayList<Integer>();
for (int number : numbers) {
if (number % 2 != 0)
oddNumbers.add(number);
}
System.out.println("oddNumbers = " + oddNumbers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment