title: How can I test whether a Java collection supports the add operation?
body: <p>In Java, whether a <code>Collection</code> support <code>add</code> depends on the concrete class.
  Say I have code like:</p>
  
  <pre><code>List&lt;String&gt; otherNames = getOthers();
  names.add(myName);
  </code></pre>
  
  <p>The second line will raise <code>UnsupportedOperationException</code> if the underlying List don't support this, one common example is <code>Collections.emptyList()</code>. </p>
  
  <p>Of course, we can create a new list to hold the content, but I wonder is there is way to test the list?</p>