我在这个上浪费了太多时间。为什么此代码无法生成类的 URL?
package org.test;
import java.net.URL;
public class Testa {
public Testa() {
String resourceName = "org/test/Testa.class";
String clazz = "org.test.Testa";
try {
Class.forName(clazz);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
URL url = this.getClass().getResource(resourceName);
System.out.println("Why is this null? >>> " + url);
}
public static void main(String[] args) {
new Testa();
}
}