它应该计算字符串中匹配对的数量。
public class tests {
public static void main(String[] args) {
System.out.print("Please enter a word: ");
Scanner inpFirst = new Scanner(System.in);
String inputF = inpFirst.nextLine();
System.out.print("Please enter another word: ");
Scanner inpSecond = new Scanner(System.in);
String inputS = inpSecond.nextLine();
int lenghtF = inputF.length() - 1;
int lengthS = inputS.length() - 1;
int f = 0;
int s = 0;
int matchingPairs = 0;
while ((f < lenghtF) & (s < lengthS)) {
char testF = inputF.charAt(f);
char testS = inputS.charAt(s);
if (testF == testS) {
char testTwoF = inputF.charAt(f+1);
char testTwoS = inputS.charAt(f+1);
if (testTwoF == testTwoS)
matchingPairs = matchingPairs++;
}
System.out.println("jrfjtf");
f = f++;
s = s++;
}
System.out.println("The number of matching pairs is: " + matchingPairs);
}
}