Java Exception Rollup

Source: Internet
Author: User

1.java.lang.unsupportedoperationexception

An exception occurred in the project with an empty collection in collections Collections.emptylist () when added:

List<car> carlist= collections.emptylist ();

Reported errors are as follows:

Java.lang.UnsupportedOperationException

At Java.util.AbstractList.add (abstractlist.java:131)

At Java.util.AbstractList.add (abstractlist.java:91)

...........

The JDK API is interpreted as follows:

Java.lang.CloneNotSupportedException
Cloning exceptions are not supported. When the Cloneable interface is not implemented or the Clone method is not supported, the exception is thrown by calling its clone () method.

When Carlist executes Remove,add method, this exception is thrown, to see the source can be learned that Emptylist does not provide the add and remove methods

WORKAROUND: It is recommended to use list<car> Carlist = new arraylist<car> ();

Java Exception Rollup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.