0

Hi I'm not to sure how to do this but here's the code that I've got

// splits 1 to 3
int check;
for (int i = 0; i < 100; i++)
{
    check = alM1((rand.next(20))+1);//error
    if (!(alM3.Contains(check)))
        alM3.Add(check);
    if (alM3.Length == 10)
        break;
}
// removes 3 from 1
for (int i = 0; i < 10; i++)
{
    if (alM1.Contains(alM3(i)))  //error
        alM1.Remove(alM3(i));    //error
}

The error message says ArrayList is a variable but it is used like a method. How can I write it so it produces what I want. Thank in advance T

2
  • 2
    to access array list entries you have to use al[i], not al(i) Commented Jul 29, 2013 at 11:18
  • check = alM1((rand.next(20))+1);//error - There are too more closing brackets Commented Jul 29, 2013 at 11:19

1 Answer 1

1

To access entries of the list you need to use square bracket notation. For example:

check = alM1[(rand.next(20))+1];

and:

if (alM1.Contains(alM3[i]))   
Sign up to request clarification or add additional context in comments.

3 Comments

Hi I've got the second one working thanks. But the top one no thanks for help
Veritable being used like a method
Got it. Check = (int)alM1[(rand.next(20) + 1)]; had to cast object to int. thanks for help have a nice day

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.