0

I have a function. I like my function. It makes lists and it makes me happy. My IDE gives me a warning about my function though, talking about potential heap pollution. I can add an annotation to suppress this warning, but I want to make sure I'm not suppressing a legitimate concern. Can anyone confirm whether the function below is safe/unsafe?

public static <T> List<T> listIt(T... t) {
    List<T> lzt = new ArrayList<T>();
    for (T i: t)
        lzt.add(i);
    return lzt;
}
shmosel
  • 49,289
  • 6
  • 73
  • 138
Carl Shiles
  • 434
  • 3
  • 15

0 Answers0