homeduke Prof. Dr. Uwe Schmidt FH Wedel

Die Datei: Main.java


weiter
   1/**
   2  * ein Testprogramm fuer die Klasse ClassInfo
   3  * mit der die Laufzeit-Typinformation
   4  * angezeigt werden kann
   5  */
   6
   7//--------------------
   8
   9public
  10class Main {
  11  public
  12  static
  13  void main(String[] argv) {
  14    try {
  15      ClassInfo ci = new ClassInfo("Y");
  16      ClassInfo ii = new ClassInfo("If1");
  17
  18      System.out.println(ci.getClassInfo());
  19      System.out.println(ii.getClassInfo());
  20    }
  21    catch (Exception e) {}
  22  }
  23}
  24
  25//--------------------
  26
  27// ein paar Klassen und Schnittstellen
  28// zum Testen von ClassInfo
  29
  30class X
  31{
  32  protected
  33  int dx;
  34}
  35
  36//--------------------
  37
  38interface If0
  39{}
  40
  41//--------------------
  42
  43interface If1
  44  extends If0
  45{
  46  public static final
  47  String theQuestion = "???";
  48
  49  public
  50  void foo() throws Exception;
  51}
  52
  53//--------------------
  54
  55interface If2
  56{}
  57
  58//--------------------
  59
  60abstract
  61class Y
  62  extends X
  63  implements If1If2
  64{
  65  public static final
  66  int theAnswer = 42;
  67
  68  private
  69  int dy;
  70
  71  public
  72  Y() {}
  73
  74  private
  75  Y(String s) {}
  76
  77  protected
  78  Y(int iint j) {}
  79
  80  public
  81  void foo() throws Exception {
  82    foo();
  83  }
  84}
  85
  86//--------------------

Die Quelle: Main.java


Letzte Änderung: 29.04.2013
© Prof. Dr. Uwe Schmidt
Prof. Dr. Uwe Schmidt FH Wedel