Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList; // Include this import at the beginning of your code
- // Lets make some PVector objects with X and Y positions based on the object class
- PVector vector1 = new PVector(10, 20);
- PVector vector2 = new PVector(15, 30);
- PVector vector3 = new PVector(20, 40);
- PVector vector4 = new PVector(25, 50);
- PVector vector5 = new PVector(30, 60);
- // Now lets add them to a new arraylist
- ArrayList<PVector> listOfPVectors = new ArrayList<PVector>();
- listOfPVectors.add(vector1);
- listOfPVectors.add(vector2);
- listOfPVectors.add(vector3);
- listOfPVectors.add(vector4);
- listOfPVectors.add(vector5);
- // Finally, now we have some objects in our list, lets iterate through all of them
- for(int index = 0; index < listOfPVectors.size(); index ++) {
- PVector pvector = listOfPVectors.get(index);
- System.out.println(pvector.getXPosition());
- System.out.println(pvector.getYPosition());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement