File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why no error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why no error" Watch "why no error" New topic
Author

why no error

Niu Xiuyuan
Ranch Hand

Joined: Jun 08, 2001
Posts: 68

i think it would be occur an UnsupportedOperationException but..everything is ok, why??


Sun Certified Java Programmer<br />Sun Certified Web Component Developer
Guoqiao Sun
Ranch Hand

Joined: Jul 18, 2001
Posts: 317
Hi, Xiuyuan, the method
<code>
public static List unmodifiableList(List list)
Returns an unmodifiable view of the specified list. This method allows modules to provide users with "read-only" access to internal lists. Query operations on the returned list "read through" to the specified list, and attempts to modify the returned list, whether direct or via its iterator, result in an
UnsupportedOperationException.
</code>
Since you only modify the original list, so there is no UnsupportedOperatonException. If you try to modify the returned list, the exception will be thrown.
Hope it helps,

------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
try my mock exam¹² at my homepage.


Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
 
jQuery in Action, 2nd edition
 
subject: why no error