Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. package com.core.java7;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. String st = "abcotetf";
  8. int count = 0;
  9.  
  10. for(int i=0; i<st.length()-3 ; i++){
  11.  
  12. if("co".compareTo(st.substring(i, i+2))==0 && "e".compareTo(st.substring(i+3,i+4)) == 0){
  13. count++;
  14. }
  15. }
  16.  
  17. System.out.println(count);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement