Although the conditional ternary operator (?) of Java can be used in a similar way to VB's IIf function, it is not strictly equivalent. VB's IIf function needs to evaluate all arguments since it is a method (method calls always evaluate all arguments), but the ternary operator is able to bypass some evaluations (using short-circuit logic in a similar way to the logical operators && and ||).
If your VB code used IIf in a way which depended on the side-effects produced by evaluating all arguments (e.g., an argument to IIf could be a method call which changes some state), then your equivalent Java code will have to be rewritten to avoid reliance on side-effects.
Note that the newer VB If operator behaves identically to the conditional ternary operator since it is not a method, but an operator.
Use VB to Java Converter to convert from VB to Java.
VB.NET and Java Equivalents
Copyright © 2004 – 2019 Tangible Software Solutions, Inc.