Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:38:36+00:00 2026-06-06T01:38:36+00:00

I have a scenario in a java web app, where a random hexadecimal value

  • 0

I have a scenario in a java web app, where a random hexadecimal value has to be generated. This value should be within a range of values specified by me. (The range of values can be hexadecimal or integer values).

What is the most efficient way to do this> Do I have to generate a random decimal number, and then convert it to hexadecimal? Or can a value be directly generated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:38:37+00:00Added an answer on June 6, 2026 at 1:38 am

    Yes, you just generate a decimal value in your range. Something such as:

    Random rand = new Random();
    int myRandomNumber = rand.nextInt(0x10) + 0x10; // Generates a random number between 0x10 and 0x20
    System.out.printf("%x\n",myRandomNumber); // Prints it in hex, such as "0x14"
    // or....
    String result = Integer.toHexString(myRandomNumber); // Random hex number in result
    

    Hex and decimal numbers are handled the same way in Java (as integers), and are just displayed or inputted differently. (More info on that.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to implement this scenario Brief about that is have two java based
Here's the scenario: I have a multi threaded java web application which is running
I have a scenario where the base project consists of java code and web
I have a web-app with a Java back-end that uses Tomcat jdbc-pool for database
I have a scenario like this: form = MockRepository.GenerateMock<IAddAddressForm>(); mediator = new AddAddressMediator(form); The
We're developing a data heavy modular web application stack with java but have little
I have a java web application which uses spring webflow as framework. I have
I have a web service that is based on Java classes. Is it possible
The scenario is around calling an external SSL SOAP web service from within Mirth.
I have this scenario: WServer 2008, SQL Server 2005, MS Analysis services (SSAS), ISS7

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.