Class cls = MyClass.class; ClassLoader classLoader = cls.getClassLoader(); System.out.println(classLoader);
ClassLoader classLoader = ClassLoader.getSystemClassLoader(); classLoader.loadClass("com.example.MyClass");In this example, we use ClassLoader.getSystemClassLoader() to retrieve the system class loader. We then use the loadClass() method to load the MyClass class from the com.example package. By using getClassLoader(), we can determine the package library of a particular class. This is useful for dynamically loading classes and resources at runtime.