user3750317
user3750317

Reputation: 59

Can you set x == y equal to a Boolean in any any programming languages where x and y are of the same primitive type?

This may be an odd question, and generally I would just go test it, but I'm not near a computer with any IDEs, but can you set a Boolean equal to the expression x==y? The only reason I ask this is because in an if statement you can say... if(x==y) which is asking if the two are equal then do.... And if that is true then the statement x == y is evaluating to true can you set a variable to it

Upvotes: 0

Views: 158

Answers (1)

raybaybay
raybaybay

Reputation: 647

Yes you can, in Java you can do:

boolean z = (x==y);

Upvotes: 3

Related Questions