Write a programme left shifting the byte value.

Category : Java | Sub Category : Operator | By Runner Dev Last updated: 2020-09-28 18:59:23 Viewed : 205


(Operator)

Write a programme left shifting the byte value.

 


Source Code: ByteShift.java

 /**

 * Write a programme left shifting the byte value.

 *

 */

 

public class ByteShift { // class name

     public static void main(String args[]) { // main body of programme start from here

           byte a = 64, b; // Declare a

           int i; // declare i

           i = a << 2; // Decare i is lessthan 2

           b = (byte) (a << 2); // convert data type

 

           System.out.println("orignal value of a: " + a); // print value of a

           System.out.println("i and b:" + i + " " + b); // print value of i and b

     } // main of main programme

} // end of class

 OutPut:

orignal value of a: 64

i and b:256 0


Search
Related Articles

Leave a Comment: