![Avatar of Moshi Mosh](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
Moshi Mosh
asked on
OutOfBoundsException
Array Out of Bounds:
Dear Experts,
I have tested the following code below and have come across some minor issues. The following is to accept input from the user with two exceptions thrown as a result if there is an out-of-bounds and or if the user inputs the wrong substring length. The code must use a substring and a split() method, as well as a loop in the catch exception.
The output is suppose to be as followed if requirements are not met. If the requirements are meet they are displayed:
Enter your full name: Marie Janet
Marie Janet
Enter the beginning and ending index number of your lastname: 4 9
Not correct number for extracting your last name.
Enter the beginning and ending index number of your lastname: 42 42
Not correct number for extracting. String index out of range: 42
The following code is attached.
EDIT: Hello Experts the code is here: abound.java
Dear Experts,
I have tested the following code below and have come across some minor issues. The following is to accept input from the user with two exceptions thrown as a result if there is an out-of-bounds and or if the user inputs the wrong substring length. The code must use a substring and a split() method, as well as a loop in the catch exception.
The output is suppose to be as followed if requirements are not met. If the requirements are meet they are displayed:
Enter your full name: Marie Janet
Marie Janet
Enter the beginning and ending index number of your lastname: 4 9
Not correct number for extracting your last name.
Enter the beginning and ending index number of your lastname: 42 42
Not correct number for extracting. String index out of range: 42
The following code is attached.
EDIT: Hello Experts the code is here: abound.java
![Avatar of Jeffrey Dake](https://filedb.experts-exchange.com/files/public/2014/3/17/21b92b12-7eb2-46ca-b835-5253cb44027f.jpeg)
So what part are you currently struggling with? Do you want help with compile errors or are you looking for validation with your approach?
![Avatar of Moshi Mosh](https://cdn.experts-exchange.com/images/experts-exchange/avatar-01-large.gif)
ASKER
Hello Expert(s)
The part that i'm struggling with is the Try/Catch area including the substring and variable containing the splitted line. This includes comparing the substring and index string to one another by using equals(). Currently, everything not commented runs. The output is suppose to display an error after the catch exception if input is not correct, or becomes Out Of Bounds.
The part that i'm struggling with is the Try/Catch area including the substring and variable containing the splitted line. This includes comparing the substring and index string to one another by using equals(). Currently, everything not commented runs. The output is suppose to display an error after the catch exception if input is not correct, or becomes Out Of Bounds.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
![Avatar of girionis](https://filedb.experts-exchange.com/files/public/2013/11/18/58dd2b86-291b-4b44-ae70-8430fecffc39.png)
Your code won't even compile. Please post valid code.
You don't seem to have posted the code.:)