Write a Program the Use of Simple If Else in Java Programming Language.

public class Simple_if_else {
	public static void main(String[] args) {
		// change the value of String "Green" to "Red" and see Message Will be change.
		String trafficSignal = "Green";
		if (trafficSignal == "Red") {
			System.out.println("Stop");
		} else {
			System.out.println("Go...");
		}
	}
}

Output:

Simple_if_else

(Visited 88 times, 1 visits today)
Share with Friends :
Written by: