CORE API / NOTES</>↗Core API20 Mar 2010
If you want to clear a buffer, but you want to keep the unread data in the buffer then you need to use the compact() method of the buffer. The compact() method will copy the unread data to the beginning of the buffer and set the position right after the unread data. The limit itself […]
CORE API / NOTES</>↗Core API18 Mar 2010
The code below show you how to clear a buffer using the clear() method call. The clear method call set the position in the buffer to 0 and limit to the capacity of the buffer. We usually call the clear() method after we read the entire content of a buffer and clear it for ready […]
CORE API / NOTES</>↗Core API17 Mar 2010
The code below show you how to get the signum function of a number using the Math.signum() static method call. This method extracts the sign of a real number. If you have a number of x, the signum function of x is -1 if x < 0; 0 if x = 0 and 1 if […]
CORE API / NOTES</>↗Core API17 Mar 2010
The static method Math.pow(double a, double b) can be used to raise the value specified in the a, the first argument, (the base), to the power of the value specified in b, the second argument, (the exponent). The exponent tells us how many times the base should be multiplied by itself. So, if I have […]
CORE API / NOTES</>↗Core API17 Mar 2010
We can calculate logarithm using the Math.log10() and the Math.log() static method call. package org.kodejava.math; public class LogarithmExample { public static void main(String[] args) { double number1 = 1000.0d; // Get common logarithm double log10 = Math.log10(number1); System.out.println("Common logarithm of " + number1 + " = " + log10); // Get natural logarithm double loge […]
CORE API / NOTES</>↗Core API16 Mar 2010
The example below show you some methods of the Math class that can be used to round the value of a number. These methods are Math.ceil(), Math.floor() and Math.round(). package org.kodejava.math; public class GetRoundedValueExample { public static void main(String[] args) { Double number = 1.5D; // Get the smallest value that is greater than or […]