• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

contains

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I check if a String object contains a particular character in it?

Thanks.
[ October 21, 2004: Message edited by: vasu maj ]
 
rahul V kumar
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could use indexOf
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I got it actually.

I know, I am just lazy..



vasu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic