I am trying to create a substring that allows me to have up to 6 letters of a last name, however, what seems to cause an error here when she finds a last name less than 6 letters, I was looking for a clock for a solution without sucess: /
id = firstName.substring (0,1).toLowerCase() + secondName.substring (0,6).toLowerCase(); System.out.print ("Here is your ID number: " + id);
This is .substring(0,6) . I need it to consist of 6 letters of at least 6.
Mistake:
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)
user1756421
source share