Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import java.util.ArrayList; // Include this import at the beginning of your code
  2.  
  3. // Lets make some PVector objects with X and Y positions based on the object class
  4. PVector vector1 = new PVector(10, 20);
  5. PVector vector2 = new PVector(15, 30);
  6. PVector vector3 = new PVector(20, 40);
  7. PVector vector4 = new PVector(25, 50);
  8. PVector vector5 = new PVector(30, 60);
  9.  
  10. // Now lets add them to a new arraylist
  11. ArrayList<PVector> listOfPVectors = new ArrayList<PVector>();
  12. listOfPVectors.add(vector1);
  13. listOfPVectors.add(vector2);
  14. listOfPVectors.add(vector3);
  15. listOfPVectors.add(vector4);
  16. listOfPVectors.add(vector5);
  17.  
  18. // Finally, now we have some objects in our list, lets iterate through all of them
  19. for(int index = 0; index < listOfPVectors.size(); index ++) {
  20. PVector pvector = listOfPVectors.get(index);
  21. System.out.println(pvector.getXPosition());
  22. System.out.println(pvector.getYPosition());
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement