Skip to content

Commit 7bfea36

Browse files
authored
Merge pull request #17003 from BenHelmyBen/master
This PR is related to BAEL-8145
2 parents 84f41e5 + cc2bd13 commit 7bfea36

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.baeldung.literalsyntaxforbytearraysusinghexnotation;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
public class LiteralSyntaxForByteArraysUsingHexNotation {
7+
private static final Logger logger = LoggerFactory.getLogger(LiteralSyntaxForByteArraysUsingHexNotation.class);
8+
9+
public static void initializeByteArrayWithDecimal() {
10+
byte[] byteArray = {10, 20, 30, 40, 50};
11+
for (byte b : byteArray) {
12+
logger.info("{}", b);
13+
}
14+
}
15+
16+
public static void initializeByteArrayWithHex() {
17+
byte[] byteArray = {0x0A, 0x14, 0x1E, 0x28, 0x32};
18+
for (byte b : byteArray) {
19+
logger.info("0x{:02X}", b);
20+
}
21+
}
22+
23+
public static void main(String[] args) {
24+
initializeByteArrayWithDecimal();
25+
initializeByteArrayWithHex();
26+
}
27+
28+
}

0 commit comments

Comments
 (0)