Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. public class Match{
  2.     private static boolean match(String string1,String string2){
  3.        
  4.        
  5.         if (string1.length()>string2.length()){
  6.             String temp = string1;
  7.             string1 = string2;
  8.             string2 = temp;
  9.         }
  10.        
  11.        
  12.         int length1 = string1.length();
  13.         int length2 = string2.length();
  14.        
  15.  
  16.         int index = 0;         
  17.         boolean match = false;
  18.        
  19.         for(int x=0;x<=length2-1;x++){
  20.  
  21.             if (index>length1-1) return match;
  22.             if (string2.charAt(x) == (string1.charAt(index))){
  23.                
  24.                 index++;
  25.                 match = true;
  26.             }
  27.             else{
  28.                 index=0;
  29.             }
  30.         }
  31.         return match;
  32.     }
  33.    
  34.     public static void main(String args[]){
  35.         System.out.println(match("yes","noyessssoo"));
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement