Created
January 24, 2011 16:47
-
-
Save jnslxndr/793505 to your computer and use it in GitHub Desktop.
How to use a static type on an ArrayList for easy iteration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Given we need a list of things of the same type (our class "Rect") we should do: | |
ArrayList<Rect> listOfRects = new ArrayList(); | |
// then we can easily iterate over this list with: | |
for (Rect r : listOfRects) | |
{ | |
r.someFancyMethod(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment