java.lang.ArrayIndexOutOfBoundsException: 0

How do II
I have trouble moving an array field to a String field. and get out of bounds
public static void InsertLetter_A_Cand_Email_t(
            String emailAddress,
            String strBdId,
            String strSsn) {
            int la_return = 0;      
            Statement stmt = null;
            Connection con = null;
            ResultSet rs = null;
            String sysDate = null;
            String[] sa_email = split(emailAddress, "@");
            //java.lang.ArrayIndexOutOfBoundsException: 0 below
            String str_akouser = sa_email[1];
Thank you in advance
Who is Participating?
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.

Please list the function parameter values you used when the exception occurred.
It looks like emailAddress may not have contained the @ symbol.
coolgemAuthor Commented:
Hi acharbonneau,
If the field is null then there would not be a @ symbol.
However because it is an address such as firstname.lastname @xxx.zzz.mmm
other than a null it should specify as  firstname.lastname @xxx.zzz.mmm
Print out the emailAddress as a little debugging test.  I'm sure you'll see immediately that it does not contain the value you expect it to contain.

    System.out.println("Email: " + emailAddress);
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

As has been suggested, you may be evaluating an email address that doesn't contain a "@".  If this is the case, a try/catch loop like the one below may help you to handle this exception better.  Also, I didn't know what split method you were using, but I might suggest using the split method in the String class which I demonstrated below.

String[] sa_email = emailAddress.split("@");
try {
    String str_akouser = sa_email[1];
} catch (IndexOutOfBoundsException e){
    // do whatever you want to happen when the email address being evaluated
    // doesn't contain a "@"
Or better still

String[] sa_email = emailAddress.split("@");
if ( sa_email.length == 1 ) {
  // Missing @
else if ( sa_email.length > 2 ) {
  // 2 or more @
else {
  // Just one @,

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
coolgemAuthor Commented:
Thank you esorf for your help
My pleasure.  Thanks for the points.
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.