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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:24:41+00:00 2026-06-01T18:24:41+00:00

I have a xml file having 50 different questions and i need only 15

  • 0

I have a xml file having 50 different questions and i need only 15 out of them randomly and non-repeated.I used the code below

int n = ((int)(Math.random()*100))%50;
if(temp<15)
{
    for(int i=0;i<temp;i++)
    {
        System.out.println("hello naresh");
        if(n==check[i])
        {
            n=((int)(Math.random()*100))%50;
        }
    }
    check[temp]=n;
}

temp++;
return n;

But by using this some questions are repeated.Please suggest me something which help me to generate the non-repeated questions.

  • 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-01T18:24:42+00:00Added an answer on June 1, 2026 at 6:24 pm

    By this way u can generate any no of random no.

         int max=50;
            List<Integer> indices;
        int randomIndex = 0;
    random(){
        int arrIndex = (int)((double)indices.size() * Math.random());
               System.out.println("my random no is:"+arrIndex);
               randomIndex = indices.get(arrIndex);
               indices.remove(arrIndex);
                return randomIndex;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an xml file sitemap.xml as shown below ..i need to add one
I have an XML file format that contains a structure of questions: <question id=q101>
I have an XML file which I need to parse using PHP and send
I have a WCF service that is being used to generate an XML file
We have lot of configuration files used in our application. Atleast 100 different xml
This is my ListView xml file and i have different xml for row(every item
What is the easiest way to convert xml to html? I have xml file
I have a XML file with the following data format: <net NetName=abc attr1=123 attr2=234
I have created XML file,but I can't view it/output it.I know there is no
I have parsed XML file into objects, in which each object has a 1:1

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.