[java/en] Enum Type

This commit is contained in:
Raphael Nascimento 2015-10-21 09:03:12 -03:00
parent 5a8a68988b
commit ef9331fa31

View File

@ -7,7 +7,7 @@ contributors:
- ["Simon Morgan", "http://sjm.io/"] - ["Simon Morgan", "http://sjm.io/"]
- ["Zachary Ferguson", "http://github.com/zfergus2"] - ["Zachary Ferguson", "http://github.com/zfergus2"]
- ["Cameron Schermerhorn", "http://github.com/cschermerhorn"] - ["Cameron Schermerhorn", "http://github.com/cschermerhorn"]
- ["Raphael Nascimento", "http://github.com/raphaelbn"] - ["Rachel Stiyer", "https://github.com/rstiyer"]
filename: LearnJava.java filename: LearnJava.java
--- ---
@ -138,7 +138,7 @@ public class LearnJava {
// //
// BigDecimal allows the programmer complete control over decimal // BigDecimal allows the programmer complete control over decimal
// rounding. It is recommended to use BigDecimal with currency values // 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 // BigDecimal can be initialized with an int, long, double or String
// or by initializing the unscaled value (BigInteger) and scale (int). // 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 // LinkedLists - Implementation of doubly-linked list. All of the
// operations perform as could be expected for a // operations perform as could be expected for a
// doubly-linked list. // doubly-linked list.
// Maps - A set of objects that maps keys to values. A map cannot // Maps - A set of objects that map keys to values. Map is
// contain duplicate keys; each key can map to at most one value. // 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 // HashMaps - This class uses a hashtable to implement the Map
// interface. This allows the execution time of basic // interface. This allows the execution time of basic
// operations, such as get and insert element, to remain // operations, such as get and insert element, to remain
@ -251,7 +255,7 @@ public class LearnJava {
// If statements are c-like // If statements are c-like
int j = 10; int j = 10;
if (j == 10){ if (j == 10) {
System.out.println("I get printed"); System.out.println("I get printed");
} else if (j > 10) { } else if (j > 10) {
System.out.println("I don't"); System.out.println("I don't");
@ -286,7 +290,18 @@ public class LearnJava {
// Iterated 10 times, fooFor 0->9 // Iterated 10 times, fooFor 0->9
} }
System.out.println("fooFor Value: " + fooFor); 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 // For Each Loop
// The for loop is also able to iterate over arrays as well as objects // The for loop is also able to iterate over arrays as well as objects
// that implement the Iterable interface. // that implement the Iterable interface.
@ -321,7 +336,7 @@ public class LearnJava {
// 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"; String myAnswer = "maybe";
switch(myAnswer){ switch(myAnswer) {
case "yes": case "yes":
System.out.println("You answered yes."); System.out.println("You answered yes.");
break; break;