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

  • SEARCH
  • Home
  • 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 3850810
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:04:01+00:00 2026-05-19T17:04:01+00:00

As a part of my project I need to create non repeating 2 or

  • 0

As a part of my project I need to create non repeating 2 or 3 digit random numbers by giving a set of numbers. I don’t want to implement a list or array for that, since I should get 1 random number for each function call.

I tried to do that using SecureRandom class of Java. I got help from some of the sites as well, but I am stuck in between, can we shuffle the VALUES and get it done? But I don’t know how that could be done. Can anyone help me?

import java.security.SecureRandom;
public class RandomNumber {
private static final RandomNumber rnd= new RandomNumber();

    private static final char[] VALUES = new char[] {
            '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};  
     private static final SecureRandom srn= new SecureRandom();
     public String createID()
     { 
       byte[] bytes = new byte[3]; 
       srn.nextBytes(bytes);

     }
  • 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-05-19T17:04:02+00:00Added an answer on May 19, 2026 at 5:04 pm

    Fisher-yates shuffle algorithm is the way to go. Its efficient for shuffling.
    and it works in linear time.

    here is algo

    To shuffle an array a of n elements:
      for i from n − 1 downto 1 do
           j ← random integer with 0 ≤ j ≤ i
           exchange a[j] and a[i]
    

    and the code

    for(int i=VALUES.length-1; i>0; i--){
                int rand = (int) (Math.random()*i);
                char temp = VALUES[i];
                VALUES[i] = VALUES[rand];
                VALUES[rand] = temp;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, I need to create three constructors as part of a project, one default,
as part of a project i need to create a new load balancer on
As part of my project I need to use some Unamanged code dlls in
I'm trying to mavenize a third part Eclipse's plugin, but I need to create
If you need to create some classes that are not part of the Entity
I need a simple HttpHandler to handle specific non-existant paths in my ASP.NET project.
I want to host an MVC 4 Web API project on Azure. I need
In part of my project I need to compute orientation of a patch in
I need to create a game in android for my final year project. I
I have part of a project whereby I need to send 1 to up

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.