Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. public static void incrementValue(int x) {
  2. x = x +1;
  3. }
  4. //What ever variable is passed into the function will NOT be changed
  5. //e.g. we pass variable y = 1 -> function call -> result: y=l
  6.  
  7. public static void incrementValue(int[] arr) {
  8. for (int i = 0; i < arr.length; i++) {
  9. arr[i]+=1;
  10. }
  11. }
  12. //What ever variable is passed into the function WILL be changed
  13. //e.g. we pass variable int[] y = int{1,2} -> function call -> result: y = int{2,3}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement