Reputation: 1
Really basic question here involving if statements.
If a=b and c=d
System.out.println ("True");
How would I write those if statements in Java code?
Both statements have to be true for the console to output the "True" statement.
Upvotes: 0
Views: 195
Reputation: 6881
If a, b, c and d are objects you should do this
if ((a.equals(b) && c.equals(d)) {
System.out.println("True");
}
If they are primitives such as (int, long etc. Strings are not primitives!) then use AliBZ's solution
(null checking left as an excercise for the reader)
Upvotes: 2