Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `try
- {
- String s = " LITTLE RABBIT";
- s.toUpperCase();
- int l = s.length();
- int a =0;
- char ch1, ch2;
- for( int i =0; i < l; i++)
- {
- ch1 = s.charAt(i);
- ch2 = s.charAt(i+1);
- if( ch1 == ch2)
- {
- a++;
- }
- }
- System.out.println(a);
- }
- catch(StringIndexOutOfBoundsException e)
- {
- System.out.println(e);
- }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement