Inital commit exercise 2
This commit is contained in:
parent
f1ed0953ef
commit
7a18e45212
2 changed files with 25 additions and 1 deletions
|
@ -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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue