
how to compare every character in one string with every character in other string?

public class Comparision {
public static void main(String args[]) {
String first="hellow";
String second="hellow";
boolean flag=false;
for(int i=0;i<first.length();i++) {
for(int j=0;j<second.length();j++) {
if(first.charAt(i)==second.charAt(j))
System.out.println(first.charAt(i)+" is found in second string at "+(j+1));
}
}
}
} }
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.