Using underscores with binary literals - Java Language Basics

Java examples for Language Basics:Primitive Types

Description

Using underscores with binary literals

Demo Code

public class Main {
  public static void main(String[] args) {
    byte initializationSequence = (byte) 0b01_110_010;
    byte inputValue = (byte) 0b101_11011;

    byte result = (byte) (inputValue & (byte) 0b000_11111);
    System.out.println("initializationSequence: " + Integer.toBinaryString(initializationSequence));
    System.out.println("result: " + Integer.toBinaryString(result));

  }// w  ww.j av  a 2  s .  co m
}

Related Tutorials