aufgabe 2.2 erledigt
parent
fb1e8c0b31
commit
06d8162bc8
|
@ -0,0 +1,23 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class Console {
|
||||
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
public String readString() {
|
||||
String text = input.nextLine();
|
||||
return text;
|
||||
}
|
||||
|
||||
public char[] readCharArray() {
|
||||
String text = input.nextLine();
|
||||
char[] cText = text.toCharArray();
|
||||
|
||||
return cText;
|
||||
}
|
||||
|
||||
public boolean readBoolean() {
|
||||
boolean bText = input.nextBoolean();
|
||||
return bText;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
public class DemoConsole {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Console Console = new Console();
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue