diff options
author | Adam Bard <github@adambard.com> | 2015-10-31 18:17:42 +0800 |
---|---|---|
committer | Adam Bard <github@adambard.com> | 2015-10-31 18:17:42 +0800 |
commit | af1a21f47d29da0ba93ef0ff71f9dfba960bc389 (patch) | |
tree | 24e49575129dbba8e9f407c5b084bcb78addfbef | |
parent | e87c1bfd5185deacebf21dbc9dcbf617c3c468cc (diff) | |
parent | 231b60b7c0c21e2f76a3dfc0939abe1b7efbfad3 (diff) |
Merge pull request #1931 from hopesenddreams/patch-3
Improved int division comment and code
-rw-r--r-- | java.html.markdown | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/java.html.markdown b/java.html.markdown index 1813f81c..2836f601 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -207,8 +207,8 @@ public class LearnJava { System.out.println("1+2 = " + (i1 + i2)); // => 3 System.out.println("2-1 = " + (i2 - i1)); // => 1 System.out.println("2*1 = " + (i2 * i1)); // => 2 - System.out.println("1/2 = " + (i1 / i2)); // => 0 (0.5 truncated down) - System.out.println("1/2 = " + (i1 / (i2*1.0))); // => 0.5 + System.out.println("1/2 = " + (i1 / i2)); // => 0 (int/int returns an int) + System.out.println("1/2 = " + (i1 / (double)i2)); // => 0.5 // Modulo System.out.println("11%3 = "+(11 % 3)); // => 2 @@ -416,7 +416,7 @@ public class LearnJava { // easier way, by using something that is called Double Brace // Initialization. - private static final Set<String> COUNTRIES = HashSet<String>() {{ + private static final Set<String> COUNTRIES = new HashSet<String>() {{ add("DENMARK"); add("SWEDEN"); add("FINLAND"); |