Fehler "StringIndexoutOfboundSexception" Fehler

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: Fehler "StringIndexoutOfboundSexception" Fehler

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.

Top