Changeset 265 in Java_Quellcode_SOOP_Vorlesung
- Timestamp:
- Jan 9, 2017, 5:35:15 PM (8 years ago)
- Location:
- generics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
generics/BoxMain.java
r264 r265 20 20 s = (String) r.leftBox.get(); 21 21 x = (Integer) r.rightBox.get(); 22 22 23 /**/ 23 24 StringBox sb = new StringBox(); -
generics/GenericBoxMain.java
r192 r265 4 4 5 5 public static void main(String[] args) { 6 GenericBox< Integer> b = new GenericBox<Integer>();6 GenericBox<String> b = new GenericBox<String>(); 7 7 8 b.set( 2);8 b.set("2"); 9 9 10 10 Integer i = 3; 11 11 12 int x = i;12 String x = "Hallo"; 13 13 14 14 b.set(x); 15 15 16 16 System.out.println(b); 17 18 GenericBox<GenericBox<String>> db = new GenericBox<GenericBox<String>>(); 19 20 db.set(new GenericBox<String>()); 21 22 db.get().set("Hallo innere Box"); 23 24 System.out.println(db); 25 17 26 } 18 27 } -
generics/IntBox.java
r264 r265 8 8 // erhalten. Wir wählen getInt(), jeder andere Name ist auch möglich. 9 9 // Funktioniert nicht: 10 10 11 // public int get() { 11 12 // return ((Integer) super.get()).intValue();
Note: See TracChangeset
for help on using the changeset viewer.