0

I am trying to select a random value from an Array but I don't know how can I remove it, function is properly generating random numbers from Array.

Help me Please that How can I remove selected number from my randomNumbers Array

This is My code

    static int[] randomNumbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };

public static int randomArray(){
    java.util.Random rand = new java.util.Random();
    int first = randomNumbers[rand.nextInt(randomNumbers.length)];
    return first;

}

1 Answer 1

3

No you cannot delete anything from an array.

Arrays are of fixed size in java. You can use ArrayList<Int> for your purpose.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Let me see what I can do with ArrayList<int>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.