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
About Question enthuware.ocpjp.i.v11.2.852 :
Moderator: admin
-
- Posts: 3
- Joined: Fri Aug 14, 2020 9:08 pm
- Contact:
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.852 :
please check this thread:
viewtopic.php?f=2&t=964&p=19849
viewtopic.php?f=2&t=964&p=19849
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 59 guests