Online Java Compiler By
JavaTpoint.com
public class IntegerHighestOneBitExample3 { public static void main(String[] args) { int num = 25; System.out.print("Input Number is: " + num); // returns an int value with at most a single one-bit, in the position // of the highest-order or the leftmost one-bit in the specified int value System.out.print("\nHighest 1-bit of the given integer is: "+Integer.highestOneBit(num)); int a = -20; System.out.println("\n\nInput Number is = " + a); System.out.print("Highest one bit of the given integer is = "+Integer.highestOneBit(a)); } }
Output