From e9bb96aaa1d404509bb935ba1b95d34b5e74fd6c Mon Sep 17 00:00:00 2001 From: Mathieu Gemard Date: Tue, 11 Jul 2017 11:08:23 +0200 Subject: [java/en] adding an exemple to ternary operator ?: (#2794) We could think we always had to use = with ?: --- java.html.markdown | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 9c60eabc..a27a68ca 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -463,7 +463,11 @@ public class LearnJava { // " int foo = 5; String bar = (foo < 10) ? "A" : "B"; - System.out.println(bar); // Prints A, because the statement is true + System.out.println("bar : " + bar); // Prints "bar : A", because the + // statement is true. + // Or simply + System.out.println("bar : " + (foo < 10 ? "A" : "B")); + //////////////////////////////////////// // Converting Data Types -- cgit v1.2.3