summaryrefslogtreecommitdiffhomepage
path: root/java.html.markdown
diff options
context:
space:
mode:
authorMadison Dickson <madison@mix3dstudios.com>2013-09-13 11:58:46 -0400
committerMadison Dickson <madison@mix3dstudios.com>2013-09-13 11:58:46 -0400
commit338862e732e82a45fbd8843d48492b4bd3121c0b (patch)
treea68ef003d86a8bc894d31fa2a34ab6bf77090c1c /java.html.markdown
parenta4b20388afd21d24c4bf32ddbaa52c42759a4f1d (diff)
Added '?' conditional logic example
Also added myself as a contributor.
Diffstat (limited to 'java.html.markdown')
-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
///////////////////////////////////////