Java examples for java.util:Collection Operation
Indicates if the collection has been wrapped by Collections.unmodifiableCollection(...)
//package com.java2s; public class Main { public static void main(String[] argv) { Object collection = "java2s.com"; System.out.println(isUnmodifiableCollection(collection)); }/* w ww . j a v a 2s .co m*/ /** * Indicates if the collection has been wrapped by Collections.unmodifiableCollection(...) * * @param collection * @return */ public static boolean isUnmodifiableCollection(Object collection) { // Precondition checking // if (collection == null) { return false; } // Get class // Class<?> collectionClass = collection.getClass(); return (collectionClass.getName() .startsWith("java.util.Collections$Unmodifiable")); } }