Sigmahokies Posted December 26, 2017 Share Posted December 26, 2017 Hi everyone, I am still learning Java. I am trying to create an array with images. I have images in folder, but I can't figure how to start to have images in array. How can I do that? I checked around in google, none of them make sense, more likely off topic to image icon. I need to tell java to pull all images from folder into array, so i can process programming. can you please show how to do that? Thank you so much. Gary Link to comment Share on other sites More sharing options...
justsomeguy Posted January 4, 2018 Share Posted January 4, 2018 There's an example of reading images here: https://stackoverflow.com/questions/9712160/opening-an-image You would add those to an array the same way you add anything else to an array. Link to comment Share on other sites More sharing options...
Makwana Prahlad Posted April 1, 2020 Share Posted April 1, 2020 Hello , @Sigmahokies Please try this code ,To Images in array public class DeckOfCards extends Applet { public void init() { Image[] clubs = new Image[13]; for (int i = 0; i < clubs.length; i++ ) { clubs[i] = getImage( getDocumentBase(), "c" + (i + 1) + ".gif"); } ... } } I hope this code will be usefull for you. Thank you. Link to comment Share on other sites More sharing options...
Ingolme Posted April 1, 2020 Share Posted April 1, 2020 Please do not reply to old topics. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now