Using equals() to compare strings

It was told in a previous post that when comparing two strings to use the equals()

So rather than doing something like this

package relationships;

publicclass Starter{

publicstaticvoid main(String[] args){

String foo ="foo";

String bar ="bar";

if(foo == bar){

System.out.println("Strings are logically equal");

}elseif(foo != bar){

System.out.println("Strings are not logically equal");

}

}

}

Where the console would output "Strings are not logically equal" How would I do this using the equals() (other then using else)

package relationships;

publicclass Starter{

publicstaticvoid main(String[] args){

String foo ="foo";

String bar ="bar";

if(foo.equals(bar)){

System.out.println("Strings are logically equal");

}elseif(/* WHAT GOES HERE? */ ){

System.out.println("Strings are not logically equal");

}

}

}

I know to test if they are equal just to go like this foo.equals(bar) but what would I put in the else if?

else if( /* WHAT GOES HERE? */ )

[2379 byte] By [SidewinderXa] at [2007-11-26 14:53:46]
# 1
Use:elseby itself, or useelse if (!foo.equals(bar))The ! unary operator returns false if the boolean being tested is true, and true if the tested boolean is
Lord_Jirachia at 2007-7-8 8:42:09 > top of Java-index,Java Essentials,Java Programming...
# 2
> Where the console would output "Strings are not> logically equal" How would I do this using the> equals() (other then using else)You don;t need anything else. If it is not true it is false there isn't a third boolean value of maybe or perhaps.
cotton.ma at 2007-7-8 8:42:09 > top of Java-index,Java Essentials,Java Programming...