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 – Observer
Guide to CopyOnWriteArrayList
Java Program to Compute Determinant of a Matrix
Java Program to Check if a Point d lies Inside or Outside a Circle Defined by Points a, b, c in a Pl...
Biểu thức Lambda trong Java 8 – Lambda Expressions
Java Program to Describe the Representation of Graph using Incidence List
Hướng dẫn sử dụng Lớp FilePermission trong java
Java Program to Find Number of Spanning Trees in a Complete Bipartite Graph
Java Program to Implement Quick Hull Algorithm to Find Convex Hull
Java Program to Implement Sorted Circular Doubly Linked List
Java 8 Stream API Analogies in Kotlin
Làm thế nào tạo instance của một class mà không gọi từ khóa new?
Guide to the Java ArrayList
Java Program to Implement Fermat Primality Test Algorithm
Java Program to Implement LinkedHashSet API
An Introduction to Java.util.Hashtable Class
Tạo số và chuỗi ngẫu nhiên trong Java
HttpClient 4 – Send Custom Cookie
Java Program to Implement Min Hash
Java Program to Implement Double Order Traversal of a Binary Tree
Spring Security Form Login
Java – Rename or Move a File
OAuth2 Remember Me with Refresh Token
Vector trong Java
Immutable Objects in Java
Java Program to Implement ConcurrentLinkedQueue API
Spring Boot - Google OAuth2 Sign-In
Map Serialization and Deserialization with Jackson
Creating a Web Application with Spring 5
Lớp Collections trong Java (Collections Utility Class)
Java Program to Implement Bellman-Ford Algorithm
Java Program to Find the Peak Element of an Array O(n) time (Naive Method)