Does <T> need to be imported as a class for this to work?

Posted by zxc on Stack Overflow See other posts from Stack Overflow or by zxc
Published on 2010-04-01T06:40:58Z Indexed on 2010/04/01 6:43 UTC
Read the original article Hit count: 218

Filed under:

In order for this to work, do you have to have an import statement for the T class?

private static <T> void invertOrdering(List<T> list) {
  for (int i = 0; i < list.size() / 2; i++) {
    int j = list.size() - 1 - i;
    T item1 = list.get(i);
    T item2 = list.get(j);
    list.set(i, item2);
    list.set(j, item1);
  }
}

© Stack Overflow or respective owner

Related posts about java