Explain this code


#1



I really dont know what they mean at
char canDrive = (fuelLe BLABLABLABLABLABLABLABLA

public class Ternary {
	public static void main(String[] args) {
		
		int fuelLevel = 3;

		char canDrive = (fuelLevel > 0) ? 'Y' : 'N';
		System.out.println(canDrive);

	}
}


#2

Yes, i know the answer but i dont know what it means.


#3

Well scrap that i already know it now


#4

The fuel level is set to 3
Now,
char canDrive = (fuelLevel > 0) ? 'Y' : 'N';
This can be read as if fuelLevel is greater than 0 the 'Y' ( canDrive the vehicle) it will return Y else 'N' (cant drive) it will return N


#5

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