From 127773d1d92d16f335244a13ba5c00f5d86d37a8 Mon Sep 17 00:00:00 2001 From: lorinakin Date: Mon, 8 Apr 2024 10:45:29 +0200 Subject: [PATCH] test --- Übung 2/src/DemoConsole.java | 18 ++++++++++++++++++ Übung 2/src/Übung.java | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Übung 2/src/DemoConsole.java diff --git a/Übung 2/src/DemoConsole.java b/Übung 2/src/DemoConsole.java new file mode 100644 index 0000000..ad6b9b2 --- /dev/null +++ b/Übung 2/src/DemoConsole.java @@ -0,0 +1,18 @@ +public class DemoConsole { + public static void main(String[] args) throws Exception { + System.out.println("Text eingeben: "); + String text = Console.readString(); + System.out.println("Gelesener Text: " + text); + + System.out.println("Text eingeben: "); + char [] ca = Console.readCharArray(); + System.out.println("Gelesenes char-Feld: "); + for(char celement: ca) + System.out.print(celement); + System.out.println(); + + System.out.println("Boolean eingeben: "); + boolean b = Console.readBoolean(); + System.out.println("Gelesener Wert: " + b); + } +} diff --git a/Übung 2/src/Übung.java b/Übung 2/src/Übung.java index eab92fa..3b499d8 100644 --- a/Übung 2/src/Übung.java +++ b/Übung 2/src/Übung.java @@ -1,4 +1,18 @@ - +import java.io.*; public class Übung { + public static void main(String[] args) throws Exception { + Console cons = System.console(); + System.out.println("Text eingeben: "); + String text = cons.readLine(); + System.out.println("Gelesener Text: " + text); + + System.out.println("Text eingeben: "); + String text2 = cons.readLine(); + for(int i = 0; i