Ich habe ein kleines Problem mit der Verknüpfung von Datei-und String-Arrays zusammen ..... Ich möchte jedes Element des Datei-Array mit der entsprechenden Nummer in der String-Array, z (Match word [1] to answer [1]) Ich habe keine Ahnung davon .... danke für die Hilfe!Verknüpfen eines Datei-Arrays mit einem String-Array
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){
}
});
}
}
Wenn du 'word [1]' mit 'answer [1]' 'du .... * ehhhh * .... übereinstimmen willst, hast du es einfach getan. Sie haben den * gleichen * Indexwert. So sind sie abgestimmt. Was war dein Problem? – Andreas