1.

Unsupported Operation Exception in Java

Answer»

Unsupported Operation Exception is an exception THROWN by Java during the time of EXECUTION of the Java program. It is included in the java.lang package.

Unsupported Operation Exception is a PART of the Collections framework in Java.

It is a subclass of the Runtime Exception class which is a subclass of the Exception class which, in turn extends the THROWABLE class.

The class definition is as follows:

public class Unsupported Operation Exception extends Runtime Exception

Here is a sample program for Unsupported Operation Exception:

import java.util.*; public class Example {  public static void main(String[] args)  {    List aList = new ArrayList();    aList.add('a');    aList.add('b');    List newList = Collections.unmodifiableList(aList);    newList.add('c');  } }

The output displays an error:

$javac Example.java. $java Example Exception in THREAD "main" java.lang.Unsupported Operation Exception at java.util.Collections$UnmodifiableCollection.add(Collections.java:1055) at Example.main(Example.java:10)


Discussion

No Comment Found