Codekru

Integer.numberOfLeadingZeros() method in Java

The numberOfLeadingZeros() is a static method of the Integer wrapper class that counts the number of zero bits preceding the highest-order (“leftmost”) one-bit in the two’s complement binary representation. In this post, we are going to look at the numberOfLeadingZeros() method in detail. Method declaration – public static int numberOfLeadingZeros(int i) What does it do? […]

Integer.numberOfLeadingZeros() method in Java Read More »

Integer.compare() and Integer.compareUnsigned() methods

compare() method is used to compare two values numerically, whereas compareUnsigned() compares two values by treating them as unsigned. This post will look in detail at the Integer class’s compare() and compareUnsigned() methods. public static int compare(int x, int y) public static int compareUnsigned(int x, int y) Let’s look at both of them one by

Integer.compare() and Integer.compareUnsigned() methods Read More »

Wrapper Classes in Java

In this post, we will discuss the wrapper classes of Java in detail. Wrapper classes provide a mechanism to “wrap” primitive values in an object so that primitives can be used for the operations reserved for the objects, like being used in a map or Collections. The wrapper classes can be used in the process

Wrapper Classes in Java Read More »