import java.awt.Point; public class Call_by_Value3 { public static void main(String[] args) { Point p1 = new Point(0, 0); Point p2 = new Point(100, 100); System.out.println("p1: " + p1.x + "|" + p1.y); // p1: 0|0 System.out.println("p2: " + p2.x + "|" + p2.y); // p2: 100|100 changePointValue(p1, p2); System.out.println("nach Methodendurchlauf:"); System.out.println("p1: " + p1.x + "|" + p1.y); // p1: 50|50 System.out.println("p2: " + p2.x + "|" + p2.y); // p2: 100|100 } private static void changePointValue(Point pp1, Point pp2){ System.out.println("Innerhalb changePointValue()"); pp1.x = 50; pp1.y = 50; System.out.println("nach Wertezuweisung:"); System.out.println("pp1: " + pp1.x + "|" + pp1.y); // p1: 50|50 System.out.println("pp2: " + pp2.x + "|" + pp2.y); // p2: 100|100 Point temp = pp1; pp1 = pp2; pp2 = temp; System.out.println("nach Referenztausch:"); System.out.println("pp1: " + pp1.x + "|" + pp1.y); // p1: 100|100 System.out.println("pp2: " + pp2.x + "|" + pp2.y); // p2: 50|50 } }