Let's say I have two same strings inside an ArrayList... is there a way to check for that? Also is there a way to check for how many times a string of the same exact is in the ArrayList?
So let's say I have the following a ArrayString.
os.println(itemIDdropped + "|" + spawnX + "|" + spawnY + "|" + currentMap + "|drop|" + me.getUsername());
1. 1|3|5|1|drop|Dan
2. 2|5|7|2|drop|Luke
3. 1|3|5|2|drop|Dan
4. 3|3|5|1|drop|Sally
Here is what the numbers/letters mean for the 1-4 strings... item ID, X pos, Y pos, Map it's on, command drop, user who dropped it
Then let's say I split it up doing this:
String[] itemGrnd = serverItems.get(i).split("\\|");
Now, let's say I have a for-loop like this one:
for (int i = 0; x < serverItems.size(); i++) {
System.out.println(serverItems.get(i));
}
I want to find where X, Y, and Map or in this case itemGrnd[1], itemGrnd[2], and itemGrnd[3] are the same in ANY other String in the ArrayList I found via serverItems.get(i).
And if WE DO find any... (which in the example I provide above... x, y, and map are the same for 1 and 4... then create an IF statment to do it ONCE... because I don't want to do this: (BTW I do keep track of my variables for client-side so don't worry about that. Yes I know it's named spawnX and spawnY.. that's just the current X,Y.
if (spawnX.equals(Integer.parseInt(itemGrnd[1])) &&
spawnY.equals(Integer.parseInt(itemGrnd[2])) &&
currentMap.equals(Integer.parseInt(itemGrnd[3]))) {
}
Now, if I were to do THIS.... 1 and 4 were be processed through here. I Only want do it ONCE.. at ALL times if we find multple strings (like 1 and 4)
Thanks