Problem in java ternary


public class Ternary {
public static void main(String[] args) {

	int fuelLevel = 3;

	char canDrive 



Set the canDrive variable equal to the ternary expression: (fuelLevel > 0) ? 'Y' : 'N';

but i can not understand


This means that the variable canDrive will be the result of evaluating if the variable 'fuelLevel' is greater than 0, based on that the value to set will be 'Y' if true and 'N' if false.

Something like this
char canDrive = (fuelLevel > 0) ? 'Y' : 'N';


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.