0

As the title states. In Java I'm wondering if i = 5 and I do list.get(i++) will it return me the item at index 5 and then increment i to 6, or will it give me the item at index 6?

intA
  • 2,513
  • 12
  • 41
  • 66

2 Answers2

3

Post-increment. So the first one. Item at 5, then i becomes 6 on the next line. A simple demonstration,

int i = 0;
System.out.println(i++);
System.out.println(i);

prints

0
1
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

If you want to get 6th one use the below i++; list.get(i);

kattoor
  • 195
  • 14