Fehler "StringIndexoutOfboundSexception" FehlerJava

Java-Forum
Anonymous
 Fehler "StringIndexoutOfboundSexception" Fehler

Post by Anonymous »

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.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post