package org.kodejava.lang;
public class CheckForInterface {
public static void main(String[] args) {
// Checking whether Cloneable is an interface or class
Class<?> clazz = Cloneable.class;
boolean isInterface = clazz.isInterface();
System.out.println(clazz.getName() + " is an interface = " + isInterface);
// Checking whether String is an interface or class
clazz = String.class;
isInterface = clazz.isInterface();
System.out.println(clazz.getName() + " is an interface = " + isInterface);
}
}
java.lang.Cloneable is an interface = true
java.lang.String is an interface = false
Latest posts by Wayan (see all)
- How do I convert Map to JSON and vice versa using Jackson? - June 12, 2022
- How do I find Java version? - March 21, 2022
- How do I convert CSV to JSON string using Jackson? - February 13, 2022