View Single Post
  #2 (permalink)  
Old 12-05-2007, 05:30 PM
ShoeNinja's Avatar
ShoeNinja ShoeNinja is offline
Senior Member
 
Join Date: Oct 2007
Posts: 123
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
You could just check the character right after the 1 that you find and make sure it isn't a 1 as well.

Code:
int i = String.indexOf("1"); if( i != -1 && !String.charAt(i).equals("1")){ }
You could also do an indexOf("1") and an indexOf("11") and compare them. If they are the same then you have 11 and not 1.

The problem with these solutions is that they are very specific. I would probably write my own method using the first technique. I would pass it the character to look for and it would return the position only if the character was repeated.
Reply With Quote