package org.kodejava.example.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("Cloneable is an interface = " + isInterface);
// Checking whether String is an interface or class
clazz = String.class;
isInterface = clazz.isInterface();
System.out.println("String is an interface = " + isInterface);
}
}
Cloneable is an interface = true
String is an interface = false
Latest posts by Wayan (see all)
- How do I create a generic class in Java? - January 1, 2021
- How do I convert java.util.TimeZone to java.time.ZoneId? - April 25, 2020
- How do I get a list of all TimeZones Ids using Java 8? - April 25, 2020