Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Is there anything like .net's NotImplementedException in java?
Are there any guidelines on exception propagation in Java? When do you add an exception to the method signature? For example: if an exception is only thrown when an essential program resource is missing, and can only be handled at the top level, do I propagate it through all methods using this exception through all the methods using the erring method? Are there any good practices? Any bad pra...
I'm converting some C# code to Java and I need to include an exception that is similar to C#'s InvalidOperationException. Does such a thing exist? Also is there a list of equivalent exception types in the two languages? Thanks. I think in my particular case IllegalStateException is most appropriate. Thanks for all the responses.
what is the standard exception to throw in Java for not supported/implemented operations
Using Collections.unmodifiableMap(...), I'm trying to return an unmodifiable view of a map. Let's say I have the following method, public final Map<Foo, Bar> getMap(){ ... return Collections.unmodifiableMap(map); } Why is it legal elsewhere to do the following, Map<Foo, Bar> map = getMap(); map.put(...); This doesn't throw an UnsupportedOperationException like I though...
I have an Interface and two Classes wich are implementing the Interface. public interface MyInterface { public void firstMethod(); public int secondMethod(); } public class MyClass1 implements MyInterface { public void firstMethod() {} } public class MyClass2 implements MyInterface { public void firstMethod() {} public int secondMethod() {} } The class MyClass1 is t...
I try to add objects in a List<String> instance but I have an error message when I submit my form! Anyone can help me? Here is my Servlet code for LDAP group creation: public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, NullPointerException{` request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8...
I have tried below code String s[]={"1","2","3","4"}; Collection c=Arrays.asList(s); System.out.println(c.remove("1") +" remove flag"); System.out.println(" collcetion "+c); I was getting Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.remove(Unknown Source) at java.util.AbstractList$Itr.remove(Unknown Source) at java.util.Abstrac...
I noticed the following in the Java Language spec in the section on enumerations here: link switch(this) { case PLUS: return x + y; case MINUS: return x - y; case TIMES: return x * y; case DIVIDE: return x / y; } throw new AssertionError("Unknown op: " + this); However, looking at the switch statement definition section, I didn't notice this particular syntax (the associated thro...
 /*
  * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Sun designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */
package java.lang;

Thrown to indicate that the requested operation is not supported.

This class is a member of the Java Collections Framework.

Author(s):
Josh Bloch
Since:
1.2
public class UnsupportedOperationException extends RuntimeException {
    
Constructs an UnsupportedOperationException with no detail message.
    public UnsupportedOperationException() {
    }

    
Constructs an UnsupportedOperationException with the specified detail message.

Parameters:
message the detail message
    public UnsupportedOperationException(String message) {
        super(message);
    }

    
Constructs a new exception with the specified detail message and cause.

Note that the detail message associated with cause is not automatically incorporated in this exception's detail message.

Parameters:
message the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
cause the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
Since:
1.5
    public UnsupportedOperationException(String messageThrowable cause) {
        super(messagecause);
    }

    
Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for exceptions that are little more than wrappers for other throwables (for example, java.security.PrivilegedActionException).

Parameters:
cause the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
Since:
1.5
    public UnsupportedOperationException(Throwable cause) {
        super(cause);
    }
    static final long serialVersionUID = -1242599979055084673L;
New to GrepCode? Check out our FAQ X