diff options
Diffstat (limited to 'java.html.markdown')
| -rw-r--r-- | java.html.markdown | 20 | 
1 files changed, 12 insertions, 8 deletions
| diff --git a/java.html.markdown b/java.html.markdown index 621d500c..ab2be4a2 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -44,8 +44,6 @@ import java.util.ArrayList;  // Import all classes inside of java.security package  import java.security.*; -// Each .java file contains one outer-level public class, with the same name -// as the file.  public class LearnJava {      // In order to run a java program, it must have a main method as an entry @@ -280,7 +278,7 @@ 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 map keys to values. Map is +        // Maps - A mapping of key Objects to value Objects. 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 @@ -289,10 +287,16 @@ public class LearnJava {          // 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 -        //            constant even for large sets. -        // TreeMap - This class is a sorted tree structure. It implements a red -        //           black tree and sorts the entries based on the key value or -        //           the comparator provided while creating the object +        //            constant-amortized even for large sets. +        // TreeMap - A Map that is sorted by its keys. Each modification  +        //           maintains the sorting defined by either a Comparator +        //           supplied at instantiation, or comparisons of each Object +        //           if they implement the Comparable interface. +        //           Failure of keys to implement Comparable combined with failure to +        //           supply a Comparator will throw ClassCastExceptions. +        //           Insertion and removal operations take O(log(n)) time +        //           so avoid using this data structure unless you are taking +        //           advantage of the sorting.          ///////////////////////////////////////          // Operators @@ -306,7 +310,7 @@ public class LearnJava {          System.out.println("2-1 = " + (i2 - i1)); // => 1          System.out.println("2*1 = " + (i2 * i1)); // => 2          System.out.println("1/2 = " + (i1 / i2)); // => 0 (int/int returns int) -        System.out.println("1/2 = " + (i1 / (double)i2)); // => 0.5 +        System.out.println("1/2.0 = " + (i1 / (double)i2)); // => 0.5          // Modulo          System.out.println("11%3 = "+(11 % 3)); // => 2 | 
