0

I am having some trouble with my code, and I am trying to figure out where each ImageButton is in my ArrayList to see if the problem is there. How do I retreive the name of an ImageButton from an ArrayList?

List<ImageButton> images = new ArrayList<ImageButton>();
images.add(imgbut1);
images.add(imgbut2);
images.add(imgbut3);
images.add(imgbut4);
images.add(imgbut5);

Here, I want to get imgbut1 for images.get(0), imgbut2 for images.get(1), etc. Something like images.get(0).getName(), images.get(1).getName(), etc

Thanks!

Evorlor
  • 7,263
  • 17
  • 70
  • 141

1 Answers1

0

imgbut1, imgbut2 are names you gave to your instances. You cannot get the name.

Here are some good examples Get name java instances

Community
  • 1
  • 1
Jeremy D
  • 4,787
  • 1
  • 31
  • 38