aspose file tools*
The moose likes Beginning Java and the fly likes contains Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "contains" Watch "contains" New topic
Author

contains

vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
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: 395
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: 805
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. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
Thanks, I got it actually.

I know, I am just lazy..



vasu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: contains