Inital commit exercise 2

This commit is contained in:
Simon Giesel 2019-05-14 13:02:04 +02:00
parent f1ed0953ef
commit 7a18e45212
2 changed files with 25 additions and 1 deletions

View file

@ -4,6 +4,13 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - GenericsAufgabe",
"request": "launch",
"mainClass": "app.GenericsAufgabe",
"projectName": "de.hhn.ai.prog2.blatt6.collections"
},
{ {
"type": "java", "type": "java",
"name": "Debug (Launch) - Current File", "name": "Debug (Launch) - Current File",
@ -16,7 +23,7 @@
"request": "launch", "request": "launch",
"mainClass": "app.App", "mainClass": "app.App",
"projectName": "de.hhn.ai.prog2.blatt6.collections", "projectName": "de.hhn.ai.prog2.blatt6.collections",
"console": "integratedTerminal", "console": "integratedTerminal"
} }
] ]
} }

View file

@ -0,0 +1,17 @@
package app;
public class GenericsAufgabe {
@SuppressWarnings("unused")
public static void main(String[] args) {
GenericsAufgabe g = new GenericsAufgabe();
String s = g.spezialmethode("Hallo");
float f = g.spezialmethode(2.3f);
char c = g.spezialmethode('a');
}
private <U> U spezialmethode(U generic) {
System.out.println(generic + " ist vom Typ " + generic.getClass());
return generic;
}
}