wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes find particular characters within a String ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "find particular characters within a String ? " Watch "find particular characters within a String ? " New topic
Author

find particular characters within a String ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
How to find particular characters within a String ? indexOf() (or) contains() (or) any other optimized way ? Which is the best option ?
Daesung Park
Ranch Hand

Joined: Mar 22, 2007
Posts: 68
I think indexOf() is enough.


Daesung Park

BLOG
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
If i use indexOf(), can i find last occurrence of a character or a substring in the invoking string (or) can i use lastIndexOf() ?
Prashant Ladha
Greenhorn

Joined: Feb 06, 2008
Posts: 8
Also, please look at regex.
Prashant Ladha
Greenhorn

Joined: Feb 06, 2008
Posts: 8
Originally posted by kri shan:
If i use indexOf(), can i find last occurrence of a character or a substring in the invoking string (or) can i use lastIndexOf() ?


yes, with lastIndexOf(String) you would get the last occurrence of that string.
 
 
subject: find particular characters within a String ?
 
Similar Threads
email hyperlink
how to find the number of characters in a string
Searching a String for a sequence of characters
how to know the string is number or charactor?
getRuntime().exec() vs cmd prompt