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 implement the Adapter pattern in Java? - December 4, 2026
- How do I display data in a JTable in Java Swing? - December 4, 2026
- How do I update task completion with state in Jetpack Compose? - December 3, 2026