This post has been edited 1 times, last edit by "Teklan" (Aug 28th 2005, 3:47pm)
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
public class Auto{ private String name = "Unbekanntes Auto"; public Auto(String name) { this.name = name; } public String getDaten(){ return name + ": Dies ist ein Auto"; } } public class Aufgabe { public static void main(String[] args){ Auto a = new Auto("Auto A"); Auto b = new Auto("Auto B"); Object[] ar = {a,b}; System.out.println( ((Auto) ar[0]).getDaten() ); System.out.println( a.getDaten() ); System.out.println( ((Auto) ar[1]).getDaten() ); System.out.println( b.getDaten() ); } } |