ListarrayList = new ArrayList<>(); boolean result = List.class.isInstance(arrayList); System.out.println(result); // true
String str = "Hello"; boolean result = String.class.isInstance(str); System.out.println(result); // trueHere, we check if a String object belongs to the String class. Since str is an instance of String class, it returns true. These examples belong to the Java core library.