How do I create an if statement that tests if all variables are equal?

omegajb24

New member
I am using Java. I need to write a statement that produces a certain output if all the variables are equal. There are 4 integers that represent separate digits in a larger integer. I need to test whether or not they are all equal. The large number is randomly generated.

I have the separate digits broken down into d1, d2, d3, and d4 variables.

Our professor hasn't really taught us how to set up a boolean expression using more then two variables. Can you even do it?

My thinking is that it should read: if(d1==d2==d3==d4).........

Obviously this isn't working for me. So how do you pull it off. I am very new to programming. Thank you.
 
Back
Top