by Anonymous » 02 Apr 2025, 04:12
Code: Select all
Code:
char a=sc.next().charAt(0);
char b=sc.nextLine().charAt(0);
System.out.println(a);
System.out.println(b);
Input: "abc"
Output: StringIndexOutOfBoundsException
Ich verstehe nicht, warum es in diesem Fall ein Fehler gibt, aber wenn ich "ABC fgh" eingehe, funktioniert es einwandfrei.
[code]Code:
char a=sc.next().charAt(0);
char b=sc.nextLine().charAt(0);
System.out.println(a);
System.out.println(b);
Input: "abc"
Output: StringIndexOutOfBoundsException
[/code]
Ich verstehe nicht, warum es in diesem Fall ein Fehler gibt, aber wenn ich "ABC fgh" eingehe, funktioniert es einwandfrei.