I have first list_session which contains 1,2,2,3 .Second list_time contains 30,17,25,46 .When second element of list_session is equals with first element, then add this time to third list_time else add value=-1 .The same for third element and fourth etc.
My code not working. Why ?
How can I modify the code ?
while (it8.hasNext()) {
tempTime = it8.next();
tempSession = it7.next();
if (testSession.equals(tempSession)) {
testSession = tempSession;
time.add(tempTime);
} else {
time.add(value);
testSession = tempSession;
}
}
for (int j = 0; j < time.size(); j++) {
System.out.println(time.get(j) + " time");
}
Firstly, If you have some Association you have to use Association List in Java is Map,
Secondly, create map where key is session ID and value list of times
Thirdly, go through map and just check 2 and more values in Values list, with some condition you want.
P.S. Do not use TWO lists instead of an Association List it makes a lot of mistakes