From 338862e732e82a45fbd8843d48492b4bd3121c0b Mon Sep 17 00:00:00 2001 From: Madison Dickson Date: Fri, 13 Sep 2013 11:58:46 -0400 Subject: Added '?' conditional logic example Also added myself as a contributor. --- java.html.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/java.html.markdown b/java.html.markdown index a2fc3630..0dec51d1 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -3,6 +3,7 @@ language: java contributors: - ["Jake Prather", "http://github.com/JakeHP"] + - ["Madison Dickson", "http://github.com/mix3d"] filename: LearnJava.java --- @@ -245,6 +246,13 @@ public class LearnJava { break; } System.out.println("Switch Case Result: " + monthString); + + // Conditional Shorthand + // You can use the '?' operator for quick assignments or logic forks. + // Reads as "If (statement) is true, use , otherwise, use " + int foo = 5 + String bar = (foo < 10) ? "A" : "B"; + System.out.println(bar); // Prints A, because the statement is true /////////////////////////////////////// -- cgit v1.2.3