// final method parameters cannot be modified in the method 

import java.awt.Point;

class TestFinal
{
  public static void main(String[] args)
  {
    Point p = new Point(1,2);
    System.out.println("p = " + p);
  
    movePoint1(p);
    System.out.println("p = " + p);

    movePoint2(p);
    System.out.println("p = " + p);

    movePoint3(p);
    System.out.println("p = " + p);
  }

  private static void movePoint1(Point p)
  {
    p.x += 10;                    // modifying a reference-type parameter
    p.y += 20;
  }

  private static void movePoint2(Point p)
  {
    p = new Point(10, 20);       // another parameter modification
  }

  private static void movePoint3(final Point p)
  {
//    p = new Point(10, 20);     // compilation error
    p.x += 20;                   // this is, however, legal
  }
}
