Use Ternary operator on double value in Java
Description
The following code shows how to use Ternary operator on double value.
Example
/* w w w. j a v a 2 s . c o m*/
public class Main {
public static void main(String[] args) {
double d = 5.0;
d *= 4.0;
System.out.println("d = " + d);
System.out.println("Ternary: " + (d == 5 ? "yes" : "no"));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »