最大6文字の姓を使用できる部分文字列を作成しようとしていますが、ここにあるものは、6文字未満の姓を見つけるとエラーをスローするようです。解決策を何時間も探していました成功しませんでした:/
id = firstName.substring (0,1).toLowerCase() + secondName.substring (0,6).toLowerCase();
System.out.print ("Here is your ID number: " + id);
です.substring(0,6)
。正確に6文字ではなく、最大6文字にする必要があります。
エラー:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 6
at java.lang.String.substring(Unknown Source)
at Test.main(Test.java:27)