From 7a18e45212e5c01332a0c4139dc1301f9f57e7be Mon Sep 17 00:00:00 2001 From: Simon Giesel Date: Tue, 14 May 2019 13:02:04 +0200 Subject: [PATCH] Inital commit exercise 2 --- .../.vscode/launch.json | 9 ++++++++- .../src/app/GenericsAufgabe.java | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 de.hhn.ai.prog2.blatt6.collections/src/app/GenericsAufgabe.java diff --git a/de.hhn.ai.prog2.blatt6.collections/.vscode/launch.json b/de.hhn.ai.prog2.blatt6.collections/.vscode/launch.json index be6973c..b751769 100644 --- a/de.hhn.ai.prog2.blatt6.collections/.vscode/launch.json +++ b/de.hhn.ai.prog2.blatt6.collections/.vscode/launch.json @@ -4,6 +4,13 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - GenericsAufgabe", + "request": "launch", + "mainClass": "app.GenericsAufgabe", + "projectName": "de.hhn.ai.prog2.blatt6.collections" + }, { "type": "java", "name": "Debug (Launch) - Current File", @@ -16,7 +23,7 @@ "request": "launch", "mainClass": "app.App", "projectName": "de.hhn.ai.prog2.blatt6.collections", - "console": "integratedTerminal", + "console": "integratedTerminal" } ] } \ No newline at end of file diff --git a/de.hhn.ai.prog2.blatt6.collections/src/app/GenericsAufgabe.java b/de.hhn.ai.prog2.blatt6.collections/src/app/GenericsAufgabe.java new file mode 100644 index 0000000..a847a03 --- /dev/null +++ b/de.hhn.ai.prog2.blatt6.collections/src/app/GenericsAufgabe.java @@ -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 spezialmethode(U generic) { + System.out.println(generic + " ist vom Typ " + generic.getClass()); + return generic; + } +} \ No newline at end of file