Monthly Archives: April 2015

How to fast calculate ( I mod N)?

Given integer I and an integer N which is power of 2, how does it work faster to calculate “I mod N”? OpenJDK’s java.util.HashMap.indexFor method gives us a best solution for it. It simply calculates ” I (bitwise AND) (N-1) … Continue reading

Posted in Java, Programming, 程式設計 | Leave a comment

Install JDK in Debian

1. Donload jdk package from Oracle: wget –header “Cookie: oraclelicense=accept-securebackup-cookie” 2. Setop JDK Environmentsudo sumkdir /opt/jdktar -zxf jdk-8u40-linux-x64.tar.gz -C /opt/jdkupdate-alternatives –install /usr/bin/java java /opt/jdk/jdk1.8.0_40/bin/java 100update-alternatives –install /usr/bin/javac javac /opt/jdk/jdk1.8.0_40/bin/javac 100 3. Check Java Environment. To check the java environment, … Continue reading

Posted in Java, Linux | Leave a comment