Question: ( Optional ) Consider the following Test.java file. / / inside main System.out.println ( foo ( Hello ) ) ; / / line 6 /
Optional Consider the following Test.java file.
inside main
System.out.println fooHello; line
more line of codes
public static int foo String sline
if slength
return ;
else
return foo ssubstring slength; line
The code compiles, but when it runs, you get the following output:
Exception in thread main java.lang.StringIndexOutOfBoundException: begin end length
at java.basejavalang.String.checkBoundsBeginEndUnknown source
at java.basejavalang.String.subStringUnknown source
at Test.fooTestjava:
at test.fooTestjava:
at Test.fooTestjava:
at test.mainTestjava:
Explain what the problem is and how it happens.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
