As part of the program that I am writing I need it to:
- Compare two strings from two different files
- Return only the true values, that is the strings that match in the files.
- Return the number of true values and what lines in the file they are located on.
The code that I have for the comparison at the moment is:
boolean result = mainEmail.trim().contentEquals(deletionemailAddress.trim());
System.out.println(mainEmail);
System.out.println(deletionemailAddress);
System.out.println(result);
It uses both trim() and contentEquals() to make sure that the two strings are the same. It then prints out a list of the strings and states whether they are the same or not. What I would like to do is to have none of the false results printed only the true statements (The mainEmail, deletionemailAddress, and result variables) to be printed. I want to count the number of true statements only and return the number of true statements as well as what lines in the mainEmail file they are located on.
What would be the most effective way in order to display only the true statements(matching emails too) and a count saying how many true statements that they are?
Have you heard about
if?