// Was ist eine Referenz ?
// walter digital © 2000

class DoppRef		// Programmklasse
{
int x;

DoppRef (int a)	// Konstruktor
    {
    x = a;
    }

void drucke (String text)	// Ausgabe
    {
    System.out.println(text + x);
    }

public static void main (String args[])	// Programmstart
  {
  DoppRef r1 = new DoppRef (5);	// Nur hier wird allokiert
  DoppRef r2 = r1;		// Zweite Referenz

  r1.drucke("Erste Ausgabe ");	// Nun kommt zweimal das Gleiche
  r2.drucke("Zweite Ausgabe ");

  r1.x = 7;			// Das Objekt wird verändert

  r1.drucke("Nach Änderung für r1 ");	// Wieder gleiche Ausgabe
  r2.drucke("Nach Änderung für r2 ");
  }
}

