wood burning stoves 2.0*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why no error
 
Similar Threads
First Java Assignment, simple problem with code.
Printing the contents of a Vector
Issue with Core:forEach Tag, or perhaps something else
Please review this code
Three Dimensional ArrayList?