tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Campbell <chris.campb...@lincmedia.co.jp>
Subject RE: Whats wrong with this code?
Date Mon, 10 Jun 2002 08:37:41 GMT

That part of the code looks ok. I suspect it is something after that which
gives you the problem - what else do you do with p? Remember indexOf returns
-1 if the substring is not found. This means that if you then use p to try
checking the name of the email like:

String namePart = em.substring(0, p); 

you will get an IndexOutOfBoundsException.

ChrisC


> This piece of code don't work if the '@' is not found:
> 
>       String em = usuario.getEmail();
>       int p = em.indexOf('@');
>       out.println(Integer.toString(p));
> 
> if the '@' is within the string, it works well. Why?

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message