String index out of bounds? (Java, substring loop)

前端 未结 5 586
感情败类
感情败类 2021-01-20 17:26

This program I\'m making for a COSC course isn\'t compiling right, I keep getting the error:

Exception in thread \"main\" java.lang.StringIndexOutOfBoundsException:

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-20 18:07

    Before loop,try below

    if(input.length()>0){
    //you code
    }
    

提交回复
热议问题