this.getClass().getClassLoader() and ClassLoader

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



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 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

How to parse mathematical expressions

java formula expression-evaluation

I'd like to understand how a Java program like GeoGebra can read a mathematical expression like exp(z^2) from a textbox and then evaluate it. For those familiar with MatLab: How do you implement fu...

Hibernate “in memory” db …and update

hibernate hsqldb

Came across a JEE demo app, where there is no hibernate dialect specified. No db config at all afaics. I assume Hibernate then generates an HSQLDB in memory?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.