[英]this.getClass().getClassLoader() and ClassLoader
What's the difference between this.getClass().getClassLoader().getResource() and ClassLoader#getResource() ? this.getClass()。getClassLoader()。getResource()和ClassLoader#getResource()有什么区别?
Frank 坦率
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()"? 您是说“ Class #getResource()”和“ ClassLoader #getResource()”之间的区别吗? If you look at JVM srcs (recommended), you will see that the first is a convenience wrapper method around the latter:
如果查看JVM srcs(推荐),您会看到第一个是围绕后者的便捷包装器方法:
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.