I'm new to Java (and to programming in general). I have a program that is supposed to run a method on two variable strings, but only if the strings are the same length and are not identical.
I've tried using
while(i < n){
if (string1.length() == string2.length() && string1 != string2){
compare(string1, string2);
i++
}
}
but it still runs the compare method even if the strings are identical.
I've also tried using
while(i < n){
if (string1.length() == string2.length(){
if (string1 == string2){
continue;
}
compare(string1, string2);
}
i++
}
but this also still runs the compare method regardless of whether or not the strings are identical.
Is there an issue with my formatting, or perhaps misused keywords? Thanks!