Guest User

Untitled

a guest
Jun 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public class Test {
  2. public static void main(String[] args) {
  3. String str1 = "I am a good boy";
  4. String [] s_str1 = str1.split(" ");
  5. String str2 = "Am a god boy";
  6. String [] s_str2 = str2.split(" ");
  7. int match = 0;
  8. for(int i=0;i<s_str1.length;i++){
  9. for(int j=0;j<s_str2.length;j++){
  10. if(s_str1[i].equalsIgnoreCase(s_str2[j])){
  11. match++;
  12. }
  13. }
  14. }
  15. int result = match*100/s_str1.length; //use length of string which is
  16. your main str
  17.  
  18. System.out.println(result);
  19. }
  20. }
Add Comment
Please, Sign In to add comment