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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:43:02+00:00 2026-06-05T12:43:02+00:00

I have an Arraylist and an Array of integer like this, ArrayList<Integer> ar= new

  • 0

I have an Arraylist and an Array of integer like this,

ArrayList<Integer> ar= new ArrayList<Integer>();
    int[] number= {0,1,2,3,4,5};

Now I want to toast the integers from this array evertime I click a button with out any repeatation. After toasting every number from this array I want to toast ‘Finished’, my logic in onclick listener is here:

Random r = new Random();

            int i1=r.nextInt(number.length-0) + 0;
            if(!ar.contains(i1)){
            Toast.makeText(getApplicationContext(), ""+i1, Toast.LENGTH_LONG).show();
            ar.add(i1);
            }else{

                Toast.makeText(getApplicationContext(), "Finished", Toast.LENGTH_LONG).show();
            }

but this didnt come to my way, It doesnt repeat any number but if it gets a duplicate number in the second click then it is toasting finished, but I want to toast it after every number from the integer array are toasted, wat should be my modified logic?

  • 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-05T12:43:03+00:00Added an answer on June 5, 2026 at 12:43 pm
    ArrayList<Integer> ar= new ArrayList<Integer>();
    int[] number= {0,1,2,3,4,5};
    for (int i : number) {
        ar.add(i);
    }
    
    Random r = new Random();
    
    // repeat this part and you will never have duplicate numbers
    int select = r.nextInt(ar.size());
    int random = ar.get(select);
    ar.remove(select);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code: static ArrayList<Integer> output_list = new ArrayList<Integer>(); static ArrayList<Integer> pair_list =
I have following ArrayList in Android: private ArrayList<Integer> Array= new ArrayList<Integer>(); It will grow
I have an array list of objects in my application. private static ArrayList<Player> userList=new
I have arraylist myorderdata . I want to retrieve this arraylist to one String
I want to put some numbers from Excel to array. Let's say I have
I have some problem to compare values from different array list From this values,
I have a hashmap like this public HashMap <String,People> valueHashMap = new Hashmap(); Here
Possible Duplicate: How to convert List<Integer> to int[] in Java? I have an ArrayList
Basically I have an integer array which i want to hand over to a
here is what i have got ArrayList<Integer> list = new ArrayList<Integer>(); Integer a =

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.