Don't understand what i'm doing wrong


#1



https://www.codecademy.com/courses/learn-java/lessons/conditionals-control-flow/exercises/ternary-conditional?action=lesson_resume

here i don't understand what i'm doing wrong. they are asking if i had set canDrive to the ternary expression or not..which i did but still showing an error...!!! below is the code which i did..

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

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

	}
}


#2

(fuelLevel>0)? 'Y' : 'N';

your code is just fine :slight_smile: . you just need a space between ) and ?


#3

oh ...thank you so much ^_^


#4

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