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 Program to Perform Search in a BST
Runnable vs. Callable in Java
CharSequence vs. String in Java
Xử lý ngoại lệ trong Java (Exception Handling)
Marker Interface trong Java
The Basics of Java Security
Getting a File’s Mime Type in Java
HashSet trong Java hoạt động như thế nào?
Java Program to Find All Pairs Shortest Path
Java Program to Generate Date Between Given Range
The Order of Tests in JUnit
Java 8 Streams peek() API
Java Program to Implement Stack API
Java Program to Construct an Expression Tree for an Prefix Expression
Java Program to Implement Naor-Reingold Pseudo Random Function
Copy a List to Another List in Java
The Difference Between map() and flatMap()
Spring WebClient vs. RestTemplate
Prevent Cross-Site Scripting (XSS) in a Spring Application
Java Timer
Java Program to Implement RoleList API
Migrating from JUnit 4 to JUnit 5
Circular Dependencies in Spring
Spring WebClient and OAuth2 Support
Java Program to Implement Fibonacci Heap
Tính trừu tượng (Abstraction) trong Java
A Guide to Spring Cloud Netflix – Hystrix
Giới thiệu Java 8
Working with Kotlin and JPA
Guava CharMatcher
Java Program to Implement CopyOnWriteArrayList API
A Guide to Apache Commons Collections CollectionUtils