willieshi232

Untitled

Dec 7th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. 12.
  2. An array transferal is when you sequentially process each element of the array, which is useful when printing the individual elements.
  3. 13.
  4. for(int i; i < data.length; i++)
  5. {
  6. System.out.println("element [" + i + "] is " + data[i]);
  7. }
  8. 14.
  9. [3, 24, 8, -5, 6, 1]
  10. 15.
  11. public static void pikachu(int[] list)
  12. {
  13. if (list.length == 0)
  14. {
  15. System.out.println("[]");
  16. }
  17. else {
  18. System.out.print("[" + list[list.length - 1]);
  19. for (int i = list.length - 2; i >= 0; i--)
  20. {
  21. System.out.print(", " + list[i]);
  22. }
  23. System.out.println("]");
  24. }
  25. }
  26. 16. Change occurences of == to an equals method
  27. 17.
  28. public static boolean allL(int[] list1, int[] list2)
  29. {
  30. if (list1.length != list2.length)
  31. {
  32. return false;
  33. }
  34. for (int i = 0; i < list1.length; i++)
  35. {
  36. if (list1[i] >= list2[i])
  37. {
  38. return false;
  39. }
  40. }
  41. return true;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment