summaryrefslogtreecommitdiffhomepage
path: root/java.html.markdown
diff options
context:
space:
mode:
authorRaphael Nascimento <raphaelbn10@gmail.com>2015-10-21 09:03:12 -0300
committerRaphael Nascimento <raphaelbn10@gmail.com>2015-10-21 09:03:12 -0300
commitef9331fa31ab84e5a04ee024ac490b24a6b5c4dc (patch)
treec5d148edf25fef04f2a3077506e85d39f77a0d1f /java.html.markdown
parent5a8a68988b7c153cf16f37c307954d7070fc9b81 (diff)
[java/en] Enum Type
Diffstat (limited to 'java.html.markdown')
-rw-r--r--java.html.markdown29
1 files changed, 22 insertions, 7 deletions
diff --git a/java.html.markdown b/java.html.markdown
index 8544ecfc..86b0578e 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -7,7 +7,7 @@ contributors:
- ["Simon Morgan", "http://sjm.io/"]
- ["Zachary Ferguson", "http://github.com/zfergus2"]
- ["Cameron Schermerhorn", "http://github.com/cschermerhorn"]
- - ["Raphael Nascimento", "http://github.com/raphaelbn"]
+ - ["Rachel Stiyer", "https://github.com/rstiyer"]
filename: LearnJava.java
---
@@ -138,7 +138,7 @@ public class LearnJava {
//
// 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.
+ // and where exact decimal precision is required.
//
// BigDecimal can be initialized with an int, long, double or String
// or by initializing the unscaled value (BigInteger) and scale (int).
@@ -185,8 +185,12 @@ public class LearnJava {
// LinkedLists - Implementation of doubly-linked list. All of the
// operations perform as could be expected for a
// doubly-linked list.
- // Maps - A set of objects that maps keys to values. A map cannot
- // contain duplicate keys; each key can map to at most one value.
+ // Maps - A set of objects that map keys to values. Map is
+ // an interface and therefore cannot be instantiated.
+ // The type of keys and values contained in a Map must
+ // be specified upon instantiation of the implementing
+ // class. Each key may map to only one corresponding value,
+ // and each key may appear only once (no duplicates).
// HashMaps - This class uses a hashtable to implement the Map
// interface. This allows the execution time of basic
// operations, such as get and insert element, to remain
@@ -251,7 +255,7 @@ public class LearnJava {
// If statements are c-like
int j = 10;
- if (j == 10){
+ if (j == 10) {
System.out.println("I get printed");
} else if (j > 10) {
System.out.println("I don't");
@@ -286,7 +290,18 @@ public class LearnJava {
// Iterated 10 times, fooFor 0->9
}
System.out.println("fooFor Value: " + fooFor);
-
+
+ // Nested For Loop Exit with Label
+ outer:
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ if (i == 5 && j ==5) {
+ break outer;
+ // breaks out of outer loop instead of only the inner one
+ }
+ }
+ }
+
// For Each Loop
// The for loop is also able to iterate over arrays as well as objects
// that implement the Iterable interface.
@@ -321,7 +336,7 @@ public class LearnJava {
// Starting in Java 7 and above, switching Strings works like this:
String myAnswer = "maybe";
- switch(myAnswer){
+ switch(myAnswer) {
case "yes":
System.out.println("You answered yes.");
break;