PersonHandler.java 862B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Created by leon on 1/24/18.
  3. */
  4. public class PersonHandler {
  5. private final Person[] personArray;
  6. public PersonHandler(Person[] personArray) {
  7. this.personArray = personArray;
  8. }
  9. public String whileLoop() {
  10. String result = "";
  11. int i=0;
  12. while(i < personArray.length){
  13. result += personArray[i];
  14. i++;
  15. }
  16. return result;
  17. }
  18. public String forLoop() {
  19. String result = "";
  20. for(int i = 0; i < personArray.length; i++){
  21. result += personArray[i];
  22. }
  23. return result;
  24. }
  25. public String forEachLoop() {
  26. String result = "";
  27. for(Object i : personArray){
  28. result += String.valueOf(i);
  29. }
  30. return result;
  31. }
  32. public Person[] getPersonArray() {
  33. return personArray;
  34. }
  35. }