About 47,700 results
Open links in new tab
  1. What is the Java ?: operator called and what does it do?

    In particular, if Java ever gets another ternary operator, people who use the term "conditional operator" will still be correct and unambiguous - unlike those who just say "ternary operator". …

  2. java - && (AND) and || (OR) in IF statements - Stack Overflow

    All the answers here are great but, just to illustrate where this comes from, for questions like this it's good to go to the source: the Java Language Specification. Section 15:23, Conditional-And …

  3. java - Multiple conditions in ternary conditional operator? - Stack ...

    Sep 23, 2012 · For the first question, you can indeed use the ternary operator, but a simpler solution would be to use a String[] with the month descriptions, and then subscript this array:

  4. How do you use the ? : (conditional) operator in JavaScript?

    Jun 7, 2011 · This is a one-line shorthand for an if-else statement. It's called the conditional operator. 1 Here is an example of code that could be shortened with the conditional operator:

  5. java - What does the colon (:) operator do? - Stack Overflow

    @user44242 Showing an example like that keeps it simple and better shows how the conditional operator works. "Why wouldn't you write boolean isNegative = number > 0;" Because that …

  6. Short form for Java if statement - Stack Overflow

    Using the conditional operator you can rewrite the above example in a single line like this: max = (a > b) ? a : b; (a > b) ? a : b; is an expression which returns one of two values, a or b.

  7. java - Differences in boolean operators: & vs && and - Stack …

    Oct 25, 2010 · I know there's a lot of answers here, but they all seem a bit confusing. So after doing some research from the Java oracle study guide, I've come up with three different …

  8. Java logical operator short-circuiting - Stack Overflow

    Jul 17, 2017 · As you can see from the preceding table, the OR operator results in true when A is true, no matter what B is. Similarly, the AND operator results in false when A is false, no …

  9. java - short-circuiting behavior of conditional OR operator ...

    Short circuiting will happen when the result of the first operand can define the outcome of the logical operation.

  10. java - Using conditional operator for long if statement - Stack …

    Aug 24, 2021 · The ternary operator generally exists to eliminate if, else, {, } and things like return and assignment in if-statements. You could potentially use it to eliminate || , && or other …