Asked • 04/14/19

In Java, what are the boolean "order of operations"?

Let's take a simple example of an object `Cat`. I want to be sure the "not null" `cat` is either orange or grey. if(cat != null && cat.getColor() == "orange" || cat.getColor() == "grey") { //do stuff } I believe AND comes first, then the OR. I'm kinda fuzzy though, so here are my questions: 1. Can someone walk me through this statement so I'm sure I get what happens? 2. Also, what happens if I add parentheses; does that change the order of operations? 3. Will my order of operations change from language to language?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.