3.3.3. Boolean Literals

The boolean literal represents the truth-values true or false that are denoted by the reserved literals true or false, respectively.

See the below table for possible values of boolean literals in Java.

			package javatutorial;

			/**
			 * Example usage of boolean literals
			 * 
			 * @author f5java.com
			 */
			public class BooleanLiterals {

				public static void main(String[] args) {
					
					boolean isIgnitionON = true;
					boolean isMusicPlayerON = false;
					
					if (!isIgnitionON){ // 1. turn on the ignition if engine is off
						isIgnitionON = true;
					}
					
					if (!isMusicPlayerON){ // 2. turn on the music player if it is off
						isMusicPlayerON = true;
					}
					
					// Print the values
					System.out.println("Car's ignition is on :" + isIgnitionON);
					System.out.println("Car's music player is on :" + isMusicPlayerON);		

				}
			}