CodesJava

Easy learning with example program codes

java 7 binary literals example


Binary Literals

In Java 7, the integral types (byte, short, int, and long) can also be expressed using the binary number system. To specify a binary literal, add the prefix 0b or 0B to the number.

Java binary literals example

package com.codesjava;
 
public class Java7BinaryLiterals {
	public static void main(String args[]){
		int i=0b01111;
		byte b=(byte) 0b01111;
		long l=(long) 0B01111L;
		System.out.println("i="+i);
		System.out.println("b="+b);
		System.out.println("l="+l);
	}
}




Output

i=15
b=15
l=15


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki