1:57 am - Tuesday April 23, 2019

Integer Example Program for highestOneBit(int i)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
<br />
/**<br />
*@author :CandidJava.com<br />
*@descriptions : This program explain the function using to return highest one bit value for Integer value<br />
*/<br />
public class IntHighestOneBit<br />
{<br />
public static void main(String arg[])<br />
{<br />
System.out.println(&quot;value 1=&quot;+Integer.highestOneBit(1));//to return highest bit value<br />
System.out.println(&quot;value 2=&quot;+Integer.highestOneBit(2));//to return highest bit value<br />
System.out.println(&quot;value 3=&quot;+Integer.highestOneBit(3));//to return highest bit value<br />
System.out.println(&quot;value 4=&quot;+Integer.highestOneBit(4));//to return highest bit value<br />
System.out.println(&quot;value 5=&quot;+Integer.highestOneBit(5)); //to return highest bit value<br />
System.out.println(&quot;value 8=&quot;+Integer.highestOneBit(8)); //to return highest bit value<br />
System.out.println(&quot;value 10=&quot;+Integer.highestOneBit(10)); //to return highest bit value<br />
System.out.println(&quot;value 11=&quot;+Integer.highestOneBit(11)); //to return highest bit value<br />
System.out.println(&quot;value 16=&quot;+Integer.highestOneBit(16)); //to return highest bit value<br />
System.out.println(&quot;value 30=&quot;+Integer.highestOneBit(30)); //to return highest bit value<br />
System.out.println(&quot;value 32=&quot;+Integer.highestOneBit(32)); //to return highest bit value<br />
System.out.println(&quot;value 50=&quot;+Integer.highestOneBit(50)); //to return highest bit value<br />
System.out.println(&quot;value 64=&quot;+Integer.highestOneBit(64)); //to return highest bit value<br />
System.out.println(&quot;value 64=&quot;+Integer.highestOneBit(65)); //to return highest bit value<br />
System.out.println(&quot;value 90=&quot;+Integer.highestOneBit(90)); //to return highest bit value<br />
System.out.println(&quot;value 128=&quot;+Integer.highestOneBit(128)); //to return highest bit value<br />
}
}<br />

Output:

D:CandidJavalangInteger>javac IntHighestOneBit.java
D:CandidJavalangInteger >java IntHighestOneBit
value 1=1
value 2=2
value 3=2
value 4=4
value 5=4
value 8=8
value 10=8
value 11=8
value 16=16
value 30=16
value 32=32
value 50=32
value 64=64
value 64=64
value 90=64
value 128=128

BACK

Filed in: Z-A All Java Codes

Comments are closed.