Answers for "codingbat java string 2 xyzthere"

0

codingbat java string 2 xyzthere

public boolean xyzThere(String str) {
  int flag=0;
  for(int i=0;i<str.length()-2;i++){
    if (str.substring(i,i+2).compareTo("xy")==0 & str.substring(i+1,i+3).compareTo("yz")==0){
      if ((i-1)>=0){
        if (str.charAt(i-1)!='.'){
          flag=1;
          break;
        }
        else{
          flag=0;
        }
      }
      else{
        flag=1;
        break;
        
      }
    }
    else{
      flag=0;
    }
  }
  if (flag==0){
    return false;
  }
  else{
    return true;
  }
}
Posted by: Guest on September-14-2020

Code answers related to "codingbat java string 2 xyzthere"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language