User Tools

Site Tools


java_primer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
java_primer [2020/08/21 16:01] jrsetijava_primer [2020/11/19 17:19] (current) – [LinkedHashMap] jrseti
Line 20: Line 20:
  
 ====LinkedHashMap==== ====LinkedHashMap====
 +
 +**An OrderedDict!**
  
 Same as hashMap but preserves **insertion order**. O(1) insertion and lookup. Same as hashMap but preserves **insertion order**. O(1) insertion and lookup.
Line 164: Line 166:
  
   * Char to digit: s.charAt(num2Idx) - '0'   * Char to digit: s.charAt(num2Idx) - '0'
 +
 +
 +=====TRICKS=====
 +
 +====Log and division====
 +
 +  * a / b = Math.exp(Math.log(a) - Math.log(b))
 +
 +====Random====
 +
 +<code>
 +//Random number from 0 to 5
 +Random rand = new Random(); 
 +int r = rand.nextInt(6); 
 +</code>
 +
 +or
 +
 +<code>
 +//Number between 0.0 and 1.0;
 +Math.random(); 
 +</code>
  
java_primer.1598025682.txt.gz · Last modified: 2020/08/21 16:01 by jrseti