Java Program to Generate Random Hexadecimal Byte

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:

Reactive WebSockets with Spring 5
Java Program to Perform Preorder Non-Recursive Traversal of a Given Binary Tree
Introduction to Netflix Archaius with Spring Cloud
RegEx for matching Date Pattern in Java
Entity To DTO Conversion for a Spring REST API
Java Program to Implement VList
Java Program to Implement the linear congruential generator for Pseudo Random Number Generation
Introduction to Spring Data JDBC
Java Program to find the maximum subarray sum using Binary Search approach
Java Program to Generate Random Partition out of a Given Set of Numbers or Characters
Java Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers
Introduction to Spliterator in Java
Java Program to Compute Discrete Fourier Transform Using Naive Approach
Java Program to Check Whether an Undirected Graph Contains a Eulerian Path
Java Program to Find Second Smallest of n Elements with Given Complexity Constraint
Guide to CopyOnWriteArrayList
Reversing a Linked List in Java
Java Program to Implement AttributeList API
Changing Annotation Parameters At Runtime
Java String to InputStream
Java Scanner hasNext() vs. hasNextLine()
Add Multiple Items to an Java ArrayList
Sử dụng Fork/Join Framework với ForkJoinPool trong Java
Thực thi nhiều tác vụ cùng lúc như thế nào trong Java?
Java – InputStream to Reader
Java Program to Find the Number of Ways to Write a Number as the Sum of Numbers Smaller than Itself
Java NIO2 Path API
Apache Commons Collections Bag
Model, ModelMap, and ModelAndView in Spring MVC
Exploring the Spring 5 WebFlux URL Matching
Java Program to Find SSSP (Single Source Shortest Path) in DAG (Directed Acyclic Graphs)
How to Delay Code Execution in Java