Thursday, 24 November 2022

Find Duplicate Word in Two Strings

public static void main(String[] args) {
String str1 = "awankhede";
String str2 = "aaadeea";
char c = 0;
int i,w = 0;
int len1 = str1.length();
int len2 = str2.length();
for(i=0;i<=len1-1;i++)
{
for(int j=0;j<=len2-1;j++)
{
if(str1.charAt(i)==str2.charAt(j))
w++;
if(str1.charAt(i)==str2.charAt(j))
c=str1.charAt(i);

}

}

System.out.println("Duplicate character   " +c+"   number of times  "+(w+1));
}

--
With Warm REGARDS,

En. S. WANKHEDE

No comments:

Post a Comment

Welcome, happy learning

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...