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:

Hướng dẫn Java Design Pattern – Memento
Java Program to Solve a Matching Problem for a Given Specific Case
A Guide to Iterator in Java
Java Program to Find a Good Feedback Edge Set in a Graph
The Spring @Controller and @RestController Annotations
Wrapper Classes in Java
JUnit 5 @Test Annotation
Java Program to Implement the Edmond’s Algorithm for Maximum Cardinality Matching
Spring Security Basic Authentication
Java Program to Compute the Volume of a Tetrahedron Using Determinants
Weak References in Java
Java Program to Solve Travelling Salesman Problem for Unweighted Graph
Working with Tree Model Nodes in Jackson
Java Program to Find the Longest Subsequence Common to All Sequences in a Set of Sequences
How to Use if/else Logic in Java 8 Streams
Number Formatting in Java
HttpClient 4 – Follow Redirects for POST
How to Round a Number to N Decimal Places in Java
Java Program to Find MST (Minimum Spanning Tree) using Prim’s Algorithm
Java Program to Represent Graph Using Adjacency Matrix
Logging in Spring Boot
Java Program to Implement Ternary Tree
Thực thi nhiều tác vụ cùng lúc như thế nào trong Java?
Java Program to Test Using DFS Whether a Directed Graph is Weakly Connected or Not
Quick Guide to java.lang.System
Spring Cloud AWS – RDS
Java Program to Perform Cryptography Using Transposition Technique
Java Program to Find Number of Articulation points in a Graph
Introduction to the Functional Web Framework in Spring 5
Java Program to Implement Adjacency Matrix
Java Program to Use the Bellman-Ford Algorithm to Find the Shortest Path
Hướng dẫn Java Design Pattern – Command