How to create an array of images?
I need to create a simple array of some images. So that later on I can traverse through the array 开发者_如何学Goeasily using a loop and access all the images one by one.
Just tell me the declaration part of storing the images into an array.
I will be having 5 images named as 1.png to 5.png which I need to access. Will it be a string array or integer array ?
Array of ImageIcon:
ImageIcon[] images = new ImageIcon[5];
images[0] = new ImageIcon("path/to/image");
....
Your question is confusing. You clearly know what an array is and how to use it, but you don't know what type to use? Why, whichever type you want to use, of course. You could use String, or whatever class you usually use to represent an image.
精彩评论