Explain this code


I really dont know what they mean at

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

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



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


Well scrap that i already know it now


The fuel level is set to 3
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


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