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
Moshi MoshAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
Moshi

You don't seem to have posted the code.:)
Jeffrey Dake Senior Director of TechnologyCommented:
So what part are you currently struggling with?  Do you want help with compile errors or are you looking for validation with your approach?
Moshi MoshAuthor Commented:
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.
Jeffrey Dake Senior Director of TechnologyCommented:
So it sounds like you really need to look at the flow of the code when an exception happens. So when the code throws the out of bounds exception flow of the code will immediately jump down to your catch block.  At that point you can do the System.out.println(e.getMessage());  

That will print out the message from the array out of bounds error.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
girionisCommented:
Your code won't even compile. Please post valid code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.