Generic Types, Part 1
Subject:   Dangerous approximation
Date:   2005-05-05 13:17:08
From:   lordpixel
In the article we see this statement:

" A List<?> is effectively read-only since the compiler does not allow us to invoke methods like add( ), set(), and addAll( )."

That's an attractive trap people fall into with List<?>. The trouble is it's not really true. Consider the List.clear() method. It takes no parameters and thus you can call it on a List<?>.

If you want a truly read-only list, you still need to use Collections.unmodifiableList()

1 to 1 of 1
  1. Dangerous approximation
    2007-05-17 05:42:31  y2mehul [View]

1 to 1 of 1