this.getClass().getClassLoader() and ClassLoader

What's the difference between this.getClass().getClassLoader().getResource() and ClassLoader#getResource() ?

Frank

Answers


The first is the actual code, the second is just a pointer which class/method you should use.

By the way, you should rather have asked this minor question/request-for-clarification in a comment on my answer in your previous question.


You mean difference between "Class#getResource()" and "ClassLoader#getResource()"? If you look at JVM srcs (recommended), you will see that the first is a convenience wrapper method around the latter:

public java.net.URL getResource(String name) {
    name = resolveName(name);
    ClassLoader cl = getClassLoader0();
    if (cl==null) {
        // A system class.
        return ClassLoader.getSystemResource(name);
    }
    return cl.getResource(name);
}

Need Your Help

Using Django-taggit with django-rest-framework, i'm not able to save my tags

django django-rest-framework django-taggit

I'm trying to figure it out why when i submit my form, my tags are not saved in my db. Pretty new with the django-rest-framework and Django-taggit too, i think i'm doing something wrong :)

merging two set of array values into one multidimesional array

php arrays

i'm a newbie in programming and in php too and i was wondering if anyone can help me with my array problem.