-
Array
How do i store data into a array and then print it out?
This is the code:
Code:
int NumOfTracks=Integer.parseInt(JOptionPane.showInputDialog("Enter the number of the tracks"));
for (int i=0; i<NumOfTracks; i++){
String Newtrack= JOptionPane.showInputDialog("Enter the title of track " + (i+1));
String Newtime= JOptionPane.showInputDialog("Enter the duration of the track");
String Tracks[]=new String[NumOfTracks];
for(int t=0;t<Tracks.length;t++){
Tracks[t]=(Newtrack);
}
String duration[]=new String[NumOfTracks];
for(int t=0;t<duration.length;t++){
duration[t]=(Newtime);
}
} //for loop for NumOfTracks
What is the problem?
-
For starters you're not using code tags so the code is rather hard to read...
-
You have problem with nested for loops. Just try to store data in your first loop ( Tracks[i]=(Newtrack);duration[i]=(Newtime); )