Findryan

Untitled

Nov 13th, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public class PassByReference
  2. {
  3. public static void main(String args[])
  4. {
  5. int ages[] = {10, 20, 30};
  6. for (int i=0; i<ages.length; i++)
  7. {
  8. System.out.println(ages[i]);
  9. }
  10.  
  11. test(ages);
  12. for (int i=0; i<ages.length; i++)
  13. {
  14. System.out.println(ages[i]);
  15. }
  16. }
  17.  
  18. public static void test(int arr[])
  19. {
  20. for (int i=0; i<arr.length; i++)
  21. {
  22. arr[i] = i + 100;
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment