This is the java program to randomly generate a hexadecimal byte. First random decimal byte is generated and then converted to hexadecimal form.
Here is the source code of the Java Program to Generate Random Hexadecimal Byte. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is sample program to generate random hexadeciaml bytes import java.util.Random; public class Generate_Random_Hex_Bytes { public static void main(String args[]) { Random random = new Random(); int val = random.nextInt(); String Hex = new String(); Hex = Integer.toHexString(val); System.out.println("Random Hex Byte: " + Hex); } }
Output:
$ javac Generate_Random_Hex_Bytes.java $ java Generate_Random_Hex_Bytes Random Hex Byte: 63e15d89
Related posts:
Java 8 Stream findFirst() vs. findAny()
Java Program to Perform Insertion in a BST
@Before vs @BeforeClass vs @BeforeEach vs @BeforeAll
How to Manually Authenticate User with Spring Security
The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5
Tìm hiểu về xác thực và phân quyền trong ứng dụng
Mảng (Array) trong Java
Spring Boot - Logging