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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:33:59+00:00 2026-05-28T13:33:59+00:00

I am new to Android and also to java. in my application exactly what

  • 0

I am new to Android and also to java. in my application exactly what i need is random numbers.which will not be repeated once again.

for an example Say i have a TextView and a Button on clicking the button it should show me random numbers and those random numbers shoud not be repeated.

for this i was thinking to store the random data into array and check whether the random number is in the array or not .if it is not there in the array it will store that number for temporally .like on first click it should show me some random number like in between 1-20 say it selected 5, now this value should be stored into array and on clicking the next button if again 5 number come then it should skip this number .

Please help me regarding this,

  • 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-28T13:34:00+00:00Added an answer on May 28, 2026 at 1:34 pm

    Talking about the data structure to store your generated random consider using java.util.Set for storing unique set of numbers. TO check whether a number already exists in Set use Set#contains(Object o) method.

    CODE:

    int max = 20;
    System.out.println("Generating random integers in range 0.." + max);
    Set<Integer> set = new HashSet<Integer>(max);
    Random randomGenerator = new Random();
    while (set.size() <= max) {
      int randomInt = randomGenerator.nextInt(max+1);
      System.out.println("Generated : " + randomInt);
      if (!set.add(randomInt))
          System.out.println("Set already has: " + randomInt);
    }
    System.out.println("Set has: " + set);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to appengine. I will write application which consist of two parts.
In my Android application I need to Override the onResume() method to check which
I'm new to Android(and Java also) and I'm trying to understand what are Fields
I am very new to android. Also very new to java, so please feel
I am not a new developer to android. I have an application on the
I am completely new to android, and pretty much a Java newb. I have
Firstly I am new to android and Java so this is a beginners question.
I have a android webservice client application. I am trying to use the java
I have developed an application in android and also deployed in the mobile. While
I'm new to Android programming however I do have some Java experience. What I

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.