Link to home
Start Free TrialLog in
Avatar of Moshi Mosh
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
Avatar of Norie
Norie

Moshi

You don't seem to have posted the code.:)
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

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.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Dake
Jeffrey Dake
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your code won't even compile. Please post valid code.