Java Class InstanceOf instanceOf(Object obj, String name)

Here you can find the source of instanceOf(Object obj, String name)

Description

instance Of

License

Open Source License

Declaration

public static boolean instanceOf(Object obj, String name) throws Exception 

Method Source Code

//package com.java2s;
/*/*from w w w. jav  a2  s  .c  o  m*/
 * Copyright (C) 2010 Dimitrios Menounos
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static boolean instanceOf(Object obj, String name) throws Exception {
        return obj != null && Class.forName(name).isAssignableFrom(obj.getClass());
    }
}

Related

  1. instanceOf(Object o, Class clazz)
  2. instanceOf(Object o, Class c)
  3. instanceOf(Object o, Class... classes)
  4. instanceOf(Object obj, String className)
  5. instanceOf(Object obj, String className)
  6. instanceOf(Object object, Class clazz)
  7. instanceOfAll(Object o, Class... clazzes)
  8. instanceofByteArray(Object o)
  9. instanceOfs(Class[] classes, Object[] objs)