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 8974503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:41:42+00:00 2026-06-15T18:41:42+00:00

I am making an Array that is 10 integers long, so that each place

  • 0

I am making an Array that is 10 integers long, so that each place 0-9 contains a different integer 0-9.

I am having trouble figuring out how to check if the array already contains a certain number, and if so, regenerating a new one.

So far I have:

for (int i = 0; i < perm.length; i++)
{
    int num = (int) (Math.random() * 9); 
    int []

    perm[i] = num;   
}
  • 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-15T18:41:43+00:00Added an answer on June 15, 2026 at 6:41 pm
    Arrays.asList(perm).contains(num) 
    

    from How can I test if an array contains a certain value?

    for (int i = 0; i < perm.length; i++)
    

    this is not enough to loop like this, if collision happens some slots would have been not initalized.

    Overall, for this task you better initialize array with values in order and then shuffle it by using random permutation indexes

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

Sidebar

Related Questions

I am making a program that inserts a two-dimensional array with random integers and
I have some code that produces undefined values in an array making no sense.
I had a problem that was making the original array to change, the curious
Okay, so I'm making a dynamic 2D array in Java that implements the java.util.Collection
I m making a Shooting game, in that I want an array of ImageViews
Given an unsorted integer array, and without making any assumptions on the numbers in
I'm having trouble making this simple thing happen. I have this loop adding values
I'm attempting to create a 2D array of integers that load in data from
Right now I have an x by y array to hold integers that decide
I'm having trouble with a little program I'm making. Basically I have 6 Classes.

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.