| Author |
contains
|
vasu maj
Ranch Hand
Joined: Jul 12, 2001
Posts: 393
|
|
How do I check if a String object contains a particular character in it? Thanks. [ October 21, 2004: Message edited by: vasu maj ]
|
What a wonderful world!
|
 |
rahul V kumar
Ranch Hand
Joined: May 20, 2003
Posts: 82
|
|
|
you could use indexOf
|
 |
vasu maj
Ranch Hand
Joined: Jul 12, 2001
Posts: 393
|
|
|
I want to check whether it is there or not. I do not want to findthe index of the character. What will indexOf give me back if the character is not present in the String?
|
 |
Jeff Bosch
Ranch Hand
Joined: Jul 30, 2003
Posts: 804
|
|
|
It will return -1 if the character is not in the String. If you need information like this, the answers are readily available in the free Java API docs available from Sun. You cannot become a good Java programmer without learning how to read and research the APIs.
|
Give a man a fish, he'll eat for one day. <br />Teach a man to fish, he'll drink all your beer.<br /> <br />Cheers,<br /> <br />Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
|
 |
vasu maj
Ranch Hand
Joined: Jul 12, 2001
Posts: 393
|
|
Thanks, I got it actually. I know, I am just lazy.. vasu
|
 |
 |
|
|
subject: contains
|
|
|