About 62,100 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". Yes, the phrase "ternary operator" has stuck - my answer is part of an effort to "unstick" it, just as I try to correct the claim that "objects are passed ...

  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 operator (&&), says: The && operator is like & (§15.22.2), but evaluates its right-hand operand only if the value of its left-hand operand is true.

  3. java - What is a Question Mark "?" and Colon - Stack Overflow

    Apr 26, 2012 · This is the ternary conditional operator, which can be used anywhere, not just the print statement. It's sometimes just called "the ternary operator", but it's not the only ternary operator, just the most common one. Here's a good example from Wikipedia demonstrating how it works: A traditional if-else construct in C, Java and JavaScript is ...

  4. java - Using NOT operator in IF conditions - Stack Overflow

    Feb 19, 2020 · As a general statement, its good to make your if conditionals as readable as possible. For your example, using ! is ok.

  5. Java: Checking contents of char variable with if condition

    May 9, 2010 · Read the first part of the condition aloud: Is the choice different from Y or y?The problem is that any character is different either from Y or y.

  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 - can you have two conditions in an if statement - Stack …

    Jun 29, 2017 · If "b" is null, Java can be assured that no matter what the results of the next conditions, the answer will always be false. So it doesn't bother performing those tests. Again, that's probably more information than you're prepared to deal with at this stage, but at some point in the near future the NPE of your test will bite you.

  8. java - Can I use a conditional statement in a printf statement?

    Sep 29, 2015 · My code contains a switch statement, and in all cases there are if else statements. They are all pretty short so I was thinking about condensing the code by turning them into conditional statements. The format I was going for was... System.out.printf( (conditional-Statement ) ); Here is my if else statement for one of the cases...

  9. java - conditional statement using data types - Stack Overflow

    Jul 3, 2015 · Just curious is there a way to set an if statement condition that checks if value is equal to a data type ...

  10. inline if statement java, why is not working - Stack Overflow

    conditional statement not working Java. 1. If statement doesn't execute. 0. Java if statement not working ...