Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test {
- public static void main(String[] args) {
- String str1 = "I am a good boy";
- String [] s_str1 = str1.split(" ");
- String str2 = "Am a god boy";
- String [] s_str2 = str2.split(" ");
- int match = 0;
- for(int i=0;i<s_str1.length;i++){
- for(int j=0;j<s_str2.length;j++){
- if(s_str1[i].equalsIgnoreCase(s_str2[j])){
- match++;
- }
- }
- }
- int result = match*100/s_str1.length; //use length of string which is
- your main str
- System.out.println(result);
- }
- }
Add Comment
Please, Sign In to add comment