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 create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023