The Value of 0xFF Number and Its Uses With & Operation in Java Article by Abdallah Sawan

This commit is contained in:
AbdallahSawan 2020-10-15 23:21:47 +03:00
parent 35a9131a72
commit 1a6ff515fc
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package com.baeldung;
public class Main {
public static void main(String[] args) {
int x = 0xff;
System.out.println(x); // output is 255
byte y = (byte) 0xff;
System.out.println(y); // output is -1
int rgba = 272214023;
int r = rgba >> 24;
int g = rgba >> 16 & 0xFF;
int b = rgba >> 8 & 0xFF;
int a = rgba & 0xFF;
System.out.println(r); // output is 64
System.out.println(g); // output is 57
System.out.println(b); // output is 168
System.out.println(a); // output is 7
}
}