From ec125fb6e793f54645a6ee592e4b5dec85f22cc5 Mon Sep 17 00:00:00 2001 From: Cameron Schermerhorn Date: Wed, 7 Oct 2015 08:53:09 -0400 Subject: Add example for switching Strings + Added switch structure to demonstrate how to switch Strings + Added name to contributor list --- java.html.markdown | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 478ec683..a862d294 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -5,6 +5,7 @@ contributors: - ["Jakukyo Friel", "http://weakish.github.io"] - ["Madison Dickson", "http://github.com/mix3d"] - ["Simon Morgan", "http://sjm.io/"] + - ["Cameron Schermerhorn", "http://github.com/cschermerhorn"] filename: LearnJava.java --- @@ -275,6 +276,23 @@ public class LearnJava { break; } System.out.println("Switch Case Result: " + monthString); + + //Starting in Java 7 and above, switching Strings works like this: + String myAnswer = "maybe"; + switch(myAnswer){ + case "yes": + System.out.prinln("You answered yes."); + break; + case "no": + System.out.println("You answered no."); + break; + case "maybe": + System.out.println("You answered maybe."); + break; + default: + Sustem.out.println("You answered " + myAnswer); + break; + } // Conditional Shorthand // You can use the '?' operator for quick assignments or logic forks. -- cgit v1.2.3 From 18b1c0c4d600284a06e28b59ab1978f777ebcc77 Mon Sep 17 00:00:00 2001 From: Cameron Schermerhorn Date: Wed, 7 Oct 2015 08:56:29 -0400 Subject: Edit string switch addition + fix typos: line 284: fix prinln to println line 293: fix sustem to system --- java.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index a862d294..e567b049 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -281,7 +281,7 @@ public class LearnJava { String myAnswer = "maybe"; switch(myAnswer){ case "yes": - System.out.prinln("You answered yes."); + System.out.println("You answered yes."); break; case "no": System.out.println("You answered no."); @@ -290,7 +290,7 @@ public class LearnJava { System.out.println("You answered maybe."); break; default: - Sustem.out.println("You answered " + myAnswer); + System.out.println("You answered " + myAnswer); break; } -- cgit v1.2.3 From bf7d33037f64ea9f80f106a37929e3fdf20bd24d Mon Sep 17 00:00:00 2001 From: Cameron Schermerhorn Date: Fri, 9 Oct 2015 08:14:11 -0400 Subject: Add space to comment prior to switch string + Add space to comment (after //) prior to switch on string example --- java.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index e567b049..eb8b23e9 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -277,7 +277,7 @@ public class LearnJava { } System.out.println("Switch Case Result: " + monthString); - //Starting in Java 7 and above, switching Strings works like this: + // Starting in Java 7 and above, switching Strings works like this: String myAnswer = "maybe"; switch(myAnswer){ case "yes": -- cgit v1.2.3 From 35e89f86fe21eb2a1246357184628595f8edca5d Mon Sep 17 00:00:00 2001 From: Cameron Schermerhorn Date: Fri, 9 Oct 2015 13:31:48 -0400 Subject: Resolve merge conflict with master + added name back to contributor list --- java.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 58c19f11..3b289a6d 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -6,7 +6,7 @@ contributors: - ["Madison Dickson", "http://github.com/mix3d"] - ["Simon Morgan", "http://sjm.io/"] - ["Zachary Ferguson", "http://github.com/zfergus2"] - - ["Cameron Schermerhorn", "http://github.com/cschermerhorn"] + - ["Cameron Schermerhorn", "http://github.com/cschermerhorn"] filename: LearnJava.java --- -- cgit v1.2.3 From 8cb9e5395b2a21fe8e86455f5a5729a60435524c Mon Sep 17 00:00:00 2001 From: Robert Rose Date: Mon, 12 Oct 2015 17:19:35 -0400 Subject: Updated Java tutorial with BigInteger and BigDecimal. --- java.html.markdown | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 67e5494e..55daa5bb 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -95,11 +95,13 @@ public class LearnJava { // Note: Java has no unsigned types. // Float - Single-precision 32-bit IEEE 754 Floating Point + // 2^-149 <= float <= (2-2^-23) * 2^127 float fooFloat = 234.5f; // f or F is used to denote that this variable value is of type float; // otherwise it is treated as double. // Double - Double-precision 64-bit IEEE 754 Floating Point + // 2^-1074 <= x <= (2-2^-52) * 2^1023 double fooDouble = 123.4; // Boolean - true & false @@ -115,6 +117,34 @@ public class LearnJava { final double E; E = 2.71828; + + // BigInteger - Immutable arbitrary-precision integers + // + // BigInteger is a data type that allows programmers to manipulate + // integers longer than 64-bits. Integers are stored as an array of + // of bytes and are manipulated using functions built into BigInteger + // + // BigInteger can be initialized using an array of bytes or a string. + + BigInteger fooBigInteger = new BigDecimal(fooByteArray); + + + // BigDecimal - Immutable, arbitrary-precision signed decimal number + // + // A BigDecimal takes two parts: an arbitrary precision integer + // unscaled value and a 32-bit integer scale + // + // BigDecimal allows the programmer complete control over decimal + // rounding. It is recommended to use BigDecimal with currency values + // and where exact decimal percision is required. + // + // BigDecimal can be initialized with an int, long, double or String + // or by initializing the unscaled value (BigInteger) and scale (int). + + BigDecimal fooBigDecimal = new BigDecimal(fooBigInteger, fooInt); + + + // Strings String fooString = "My String Is Here!"; -- cgit v1.2.3 From 4010f3727b377f1aa012c5f4195e58e11cae3be4 Mon Sep 17 00:00:00 2001 From: Robert Rose Date: Mon, 12 Oct 2015 17:48:08 -0400 Subject: Added contributor credit. --- java.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 55daa5bb..b43c3a72 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -6,6 +6,7 @@ contributors: - ["Madison Dickson", "http://github.com/mix3d"] - ["Simon Morgan", "http://sjm.io/"] - ["Zachary Ferguson", "http://github.com/zfergus2"] + - ["Rob Rose", "https://github.com/RobRoseKnows"] filename: LearnJava.java --- -- cgit v1.2.3 From a811ee38e44ca5d25eaa385cd7a2de93a9d67056 Mon Sep 17 00:00:00 2001 From: Robert Rose Date: Mon, 12 Oct 2015 17:49:47 -0400 Subject: Removed credit --- java.html.markdown | 1 - 1 file changed, 1 deletion(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index b43c3a72..55daa5bb 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -6,7 +6,6 @@ contributors: - ["Madison Dickson", "http://github.com/mix3d"] - ["Simon Morgan", "http://sjm.io/"] - ["Zachary Ferguson", "http://github.com/zfergus2"] - - ["Rob Rose", "https://github.com/RobRoseKnows"] filename: LearnJava.java --- -- cgit v1.2.3 From 26696b764b83ae34bb809405ecf5cfba615aad6a Mon Sep 17 00:00:00 2001 From: Robert Rose Date: Mon, 12 Oct 2015 17:52:09 -0400 Subject: Revert "Updated Java tutorial with BigInteger and BigDecimal." This reverts commit 8cb9e5395b2a21fe8e86455f5a5729a60435524c. --- java.html.markdown | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 55daa5bb..67e5494e 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -95,13 +95,11 @@ public class LearnJava { // Note: Java has no unsigned types. // Float - Single-precision 32-bit IEEE 754 Floating Point - // 2^-149 <= float <= (2-2^-23) * 2^127 float fooFloat = 234.5f; // f or F is used to denote that this variable value is of type float; // otherwise it is treated as double. // Double - Double-precision 64-bit IEEE 754 Floating Point - // 2^-1074 <= x <= (2-2^-52) * 2^1023 double fooDouble = 123.4; // Boolean - true & false @@ -117,34 +115,6 @@ public class LearnJava { final double E; E = 2.71828; - - // BigInteger - Immutable arbitrary-precision integers - // - // BigInteger is a data type that allows programmers to manipulate - // integers longer than 64-bits. Integers are stored as an array of - // of bytes and are manipulated using functions built into BigInteger - // - // BigInteger can be initialized using an array of bytes or a string. - - BigInteger fooBigInteger = new BigDecimal(fooByteArray); - - - // BigDecimal - Immutable, arbitrary-precision signed decimal number - // - // A BigDecimal takes two parts: an arbitrary precision integer - // unscaled value and a 32-bit integer scale - // - // BigDecimal allows the programmer complete control over decimal - // rounding. It is recommended to use BigDecimal with currency values - // and where exact decimal percision is required. - // - // BigDecimal can be initialized with an int, long, double or String - // or by initializing the unscaled value (BigInteger) and scale (int). - - BigDecimal fooBigDecimal = new BigDecimal(fooBigInteger, fooInt); - - - // Strings String fooString = "My String Is Here!"; -- cgit v1.2.3 From a504713d000567919196fed9f2be44e91ba722fe Mon Sep 17 00:00:00 2001 From: Robert Rose Date: Mon, 12 Oct 2015 17:52:21 -0400 Subject: Updated Java tutorial with BigInteger and BigDecimal --- java.html.markdown | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 67e5494e..55daa5bb 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -95,11 +95,13 @@ public class LearnJava { // Note: Java has no unsigned types. // Float - Single-precision 32-bit IEEE 754 Floating Point + // 2^-149 <= float <= (2-2^-23) * 2^127 float fooFloat = 234.5f; // f or F is used to denote that this variable value is of type float; // otherwise it is treated as double. // Double - Double-precision 64-bit IEEE 754 Floating Point + // 2^-1074 <= x <= (2-2^-52) * 2^1023 double fooDouble = 123.4; // Boolean - true & false @@ -115,6 +117,34 @@ public class LearnJava { final double E; E = 2.71828; + + // BigInteger - Immutable arbitrary-precision integers + // + // BigInteger is a data type that allows programmers to manipulate + // integers longer than 64-bits. Integers are stored as an array of + // of bytes and are manipulated using functions built into BigInteger + // + // BigInteger can be initialized using an array of bytes or a string. + + BigInteger fooBigInteger = new BigDecimal(fooByteArray); + + + // BigDecimal - Immutable, arbitrary-precision signed decimal number + // + // A BigDecimal takes two parts: an arbitrary precision integer + // unscaled value and a 32-bit integer scale + // + // BigDecimal allows the programmer complete control over decimal + // rounding. It is recommended to use BigDecimal with currency values + // and where exact decimal percision is required. + // + // BigDecimal can be initialized with an int, long, double or String + // or by initializing the unscaled value (BigInteger) and scale (int). + + BigDecimal fooBigDecimal = new BigDecimal(fooBigInteger, fooInt); + + + // Strings String fooString = "My String Is Here!"; -- cgit v1.2.3