Whats wrong with this code?
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? Thanks in advance, Juan José Velázquez Garcia Web Development www.htmlspider.com.br -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Whats wrong with this code?
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:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Whats wrong with this code?
What error are you getting? --- Juan [EMAIL PROTECTED] wrote: 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? Thanks in advance, Juan José Velázquez Garcia Web Development www.htmlspider.com.br -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]