art[]=is a String array of artist names
plays[]=is an integer array of play-count for the respective artist
This data has been acquired from a huge dataset with different users. Hence,the art[] array contains duplicate artists. I need remove the duplicates and also add the play-count for the same artist received from different users.
eg-
art[beatles,floyd,beatles,dream theater,beatles,...]
plays[100,200,50,30,200,....]
I need an array which will add all the play counts for the same artist and also remove duplicates. I tried the following but it doesn't work.
for(int i=0;i<9999;i++){
for(int j=i+1;j<10000;j++){
/* if(!artistplays[i][0].equals(null) && !artistplays[j][0].equals(null) && artistplays[i][0].equalsIgnoreCase(artistplays[j][0])){
artistplays[i][1]=String.valueOf((Integer.parseInt(artistplays[i][1]))+(Integer.parseInt(artistplays[j][1])));
artistplays[j][0]=null;
artistplays[j][1]=null;
}*/ //I also tried implementing this in a 2D array where the 1st column is the artist and the 2nd column is for the respective play-count
if(!art[i].equalsIgnoreCase(null) && !art[j].equalsIgnoreCase(null) && art[i].equalsIgnoreCase(art[j])){
plays[i]+=plays[j];
art[j]=null;
plays[j]=0;
}
}
}
When I run this,the arrays don't change. Where am I going wrong?
art[i]is null. Useart[i] == nulltest instead.