Page 1 of 1

About Question enthuware.ocpjp.i.v11.2.852 :

Posted: Wed Sep 09, 2020 3:27 pm
by vikavrn90
What will the following code print? System.out.println("12345".charAt(6));

Answer:
It will throw an IndexOutOfBoundsException

but IntelliJ IDEA give output:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 6
at java.lang.String.charAt(String.java:658)
at home.Test.main(Test.java:17)

What is right ?
Thank you for helping

Re: About Question enthuware.ocpjp.i.v11.2.852 :

Posted: Wed Sep 09, 2020 6:56 pm
by admin
please check this thread:
viewtopic.php?f=2&t=964&p=19849