Hi,
For ternary conditions, I am receiving error for more than one character on the condition results. Instead of Y I used “yes” and instead on N used “No”. I am receiving error.
public class Ternary {
public static void main(String[] args) {
int fuelLevel = 3;
char canDrive =(fuelLevel > 0) ? 'Yes':'No';
System.out.println(canDrive);
}
}
The single quotations ‘_’ denote a char variable. Only a single character is allowed in this data type. “Yes” and “No” would be considered Strings and are denoted by double quotations. You will learn about them later.