PrimitiveParameters.java 933B

123456789101112131415161718192021222324252627282930313233
  1. public class PrimitiveParameters
  2. {
  3. public static void main(String[] args)
  4. { go();
  5. }
  6. public static void go()
  7. { int x = 3;
  8. int y = 2;
  9. System.out.println("In method go. x: " + x + " y: " + y);
  10. falseSwap(x,y);
  11. System.out.println("in method go. x: " + x + " y: " + y);
  12. moreParameters(x,y);
  13. System.out.println("in method go. x: " + x + " y: " + y);
  14. }
  15. public static void falseSwap(int x, int y)
  16. { System.out.println("in method falseSwap. x: " + x + " y: " + y);
  17. int temp = x;
  18. x = y;
  19. y = temp;
  20. System.out.println("in method falseSwap. x: " + x + " y: " + y);
  21. }
  22. public static void moreParameters(int a, int b)
  23. { System.out.println("in method moreParameters. a: " + a + " b: " + b);
  24. a = a * b;
  25. b = 12;
  26. System.out.println("in method moreParameters. a: " + a + " b: " + b);
  27. falseSwap(b,a);
  28. System.out.println("in method moreParameters. a: " + a + " b: " + b);
  29. }
  30. }