Java Programming 程式設計

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) “. Reference 1. “HashMap.” Available: [Online] http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/util/HashMap.java#HashMap.indexFor%28int%2Cint%29 2. “HashMap implementation in Java. How does the […]

Read More
Java Linux

Install JDK in Debian

1. Donload jdk package from Oracle: wget –header “Cookie: oraclelicense=accept-securebackup-cookie” http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.tar.gz 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, you just use this command: java –version The console will prompt message like this: java […]

Read More
Back To Top