Erhalten von "StringIndexoutOfboundSexception" -Fehler [Duplikat]

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Erhalten von "StringIndexoutOfboundSexception" -Fehler [Duplikat]

by Anonymous » 02 Apr 2025, 10:45

Der folgende Code löst StringIndexoutOfBoundSexception für die Eingabe "ABC"

Code: Select all

char a = sc.next().charAt(0);
char b = sc.nextLine().charAt(0);
Ich verstehe nicht, warum er in diesem Fall den Fehler gibt, aber wenn ich "ABC fgh" als Eingabe eingehe, funktioniert es einwandfrei.

Top