2. Referenzieren-Dereferenzieren

Submitted by javafrage on Thu, 09/05/2013 - 08:58
public class Person {
   public Person vater;
   public Person mutter;

   public static void main (String[] args ) {
      Person p1 = new Person();
      Person p2 = new Person();
      p1.vater = p2;
      p2 = null;
      // Zeitpunkt 1
     execute(p1);
     // Zeitpunkt 3
   } // Ende main

   public static void execute(Person p) {
      Person[] persFeld = new Person[2];
      persFeld[1] = p;
      persFeld[0] = new Person();
      persFeld[0].vater = new Person();
      persFeld[0].mutter = new Person();