java - Co-linking a File array with a String Array -


i have little issue linking file , string arrays together..... want match each element of file array corresponding number in string array, e.g (match word[1] answer[1]) don't have idea that.... help!

private static file[] word =       { new file ("c:\\users\\hp\\downloads\\word pronunciation\\audio.mp3"),          new file ("c:\\users\\hp\\downloads\\word pronunciation\\baby.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\board.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\bomb.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\gym.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\football.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\school.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\keyboard.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\computer.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\name.mp3"),      new file ("c:\\users\\hp\\downloads\\word pronunciation\\lady.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\church.mp3"),      new file ("c:\\users\\hp\\downloads\\word pronunciation\\sport.mp3"),      new file ("c:\\users\\hp\\downloads\\word pronunciation\\beauty.mp3"),      new file ("c:\\users\\hp\\downloads\\word pronunciation\\radio.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\prince.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\hearing.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\worship.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\song.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\flower.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\water.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\nature.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\goal.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\manifest.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\election.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\number.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\sentence.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\movie.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\sound.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\teacher.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\speed.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\time.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\debate.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\video.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\music.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\phone.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\mountain.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\drink.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\market.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\broom.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\help.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\picture.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\princess.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\cake.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\river.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\dance.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\rely.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\level.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\wealth.mp3"),     new file ("c:\\users\\hp\\downloads\\word pronunciation\\surname.mp3") };      private string []answer = {"audio", "baby", "board", "bomb", "gym", "football", "school", "keyboard", "computer", "name" ,             "lady", "church", "sport", "beauty", "radio", "prince", "hearing", "worship", "song", "flower", "water", "nature", "goal" ,             "manifest", "election", "number", "sentence", "movie", "sound", "teacher", "speed", "time", "debate", "video", "music",              "phone", "drink", "market", "broom", "help", "picture", "princess", "cake", "river", "dance", "rely", "level", "wealth", "surname"};  jbutton click = new jbutton();  public class beginner(){  click = new jbutton("1");  click.addactionlistener(new actionlistener(){  public void actionperformed (actionevent x){      } }); } } 

you're better of using map.

map<string, file> mapping = new hashmap<>(); mapping.put("audio", new file("c:\\users\\hp\\downloads\\word pronunciation\\audio.mp3"); // etc... 

and value using:

file file = mapping.get("audio"); 

Comments