ArrayList Problems / get() & remove()

Regarding why that specific error: As @josephh pointed out, you first name your ArrayList bullets and then, in your for loop, you give a single bullet the same name – bullets. So, your error that get does not exist is because bullets is now of class Bullet, not of class ArrayList, and class Bullet doesn’t have a get() method.

Two variables in different scope may have the same name – or you may redefine a variable name to point to a different object. However, redefining names can often lead to confusion.

  1. “When I say Big Red, I mean my dog.”
  2. “When I say Big Red, I mean my car.”
  3. “Please feed Big Red.”
    “…how do you feed a car?” ( method feed does not exist for object of class Car )
1 Like