summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Bard <github@adambard.com>2013-09-13 10:14:19 -0700
committerAdam Bard <github@adambard.com>2013-09-13 10:14:19 -0700
commitb1a70dd99871c0a339cf4d543f9840468ebb024b (patch)
tree71c6412604f0fab4e81d3899aaddad0d9aead317
parent925b0afd8f0d062c4e078b00fc3918089f14f303 (diff)
parent338862e732e82a45fbd8843d48492b4bd3121c0b (diff)
Merge pull request #343 from mix3d/patch-3
Added '?' conditional logic example
-rw-r--r--java.html.markdown8
1 files changed, 8 insertions, 0 deletions
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 <first value>, otherwise, use <second value>"
+ int foo = 5
+ String bar = (foo < 10) ? "A" : "B";
+ System.out.println(bar); // Prints A, because the statement is true
///////////////////////////////////////