Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Android Studio | Java | If Statements with 3+ variable comparisons using && or alternate options

I’m attempting the below:

if(p1S > p2S && p3S)

}

But the IDE doesn’t like the && here.

So, how would I compare these 3 ints to find the one with the highest value, thus moving forward.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Aka: If Int 1 is greater than int 2, and int 3, then do this. . .

I suspect I just don’t know the syntax well enough just yet. (I’ve only just started college for CS)

>Solution :

Is this what you want?

if(p1S > p2S && p1S > p3S)

}

The reason the previous code didn’t work is that the first part

if(p1S > p2S && p3S)

}

evaluates to:

if(boolean && p3S)

}

And you can’t do an && between a boolean and an int.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading