The Bitwise operators has relative low precedence. They have lower precedence than arithmatical operators. It is suggested that you use parentheses when you mix lower precendenc (bitwise opertors, ternary opertor, etc.) and high precendenc operators together.
There is no unsigned left shift operator in Java. https://www.quora.com/Why-is-there-no-unsigned-left-shift-operator-in-Java
Hashmap in Kotlin
References¶
- LinkedHashMap preserves the insertion order (which is similar to dict in Python 3.7+).
Set in Java
Reference¶
Rounding Numbers in Kotlin
System.out.printf¶
Understand System.identityHashCode in Java
Tips and Traps¶
- You cannot get the address of an object in Java (without hacking).
System.identityHashCode(obj)
is the next best thing you can have. This trick (combined with the timestamp) is used to generate default seed for random number generators in Java.
Java IO
References¶
- Generally speaking, BufferedReader/BufferedWrite are preferred over InputStreamReader/InputStreamWriter.
https://docs.oracle.com/javase/8/docs/api/java/io/BufferedWriter.html
public static Stream\<String> java.nio.file.Files.lines¶
public static List\<String> java.nio.file.Files.readAllLines¶
Read all lines from a file.
Bytes from the file are decoded into characters using the UTF-8 charset.
Notice that this method returns a List of Strings,
which is different from the method java.nio.file.Files.lines
(who returns a Stream of Strings).