共 10 篇文章 |
|
阅40 转0 评0 公众公开 16-03-06 15:30 |
public class Test { public static void main(String[] ARGSTRING) { dummy();public static void dummy() { String a = (String)null;NullPointerExceptionat Test.dummy(Test.java:15)at Test.main(Test.java:4)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorI... 阅34 转0 评0 公众公开 16-01-14 16:22 |
Inner classes are very similar to methods, they have access to all members of its outer class, and to exists/work need instance of that outer class, so while creating instance of Inner class you have to pass reference to instance of Outer class.// constructor of inner class as first argument need object of // Outer cl... 阅41 转0 评0 公众公开 16-01-13 11:10 |
【Java线程】volatile的适用场景。Volatile 变量可用于提供线程安全,但是只能应用于非常有限的一组用例:多个变量之间或者某个变量的当前值与修改后值之间没有约束。第一个条件的限制使 volatile 变量不能用作线程安全计数器。线程1执行doWork()的过程中,可能有另外的线程2调用了shutdown,所以boolean变量必须是volatile。线程 1 被线程 2 ... 阅63 转0 评0 公众公开 15-11-22 15:20 |
表示编译需要c:\classed下面的class文件,c:\jar\abc.jar里面的class文件,c:\zip\abc.zip里面的class文件还需要c:\source\project1\src下面的源文件,c:\source\project2 \lib\src.jar里面的源文件,c:\source\project3\lib\src.zip里面的源文件,注意:jar,zip里面的源文件不会有什么改动,目录下的源文件,有可能会被重新编译。 阅22 转0 评0 公众公开 15-10-16 21:52 |
Runtime Classpath vs Compile.The cases might be complicated even further, when you consider compile-time constants and version mismatches, but the general point is this: the classpaths that you use for compiling and for running the application are different, and you should be aware of that. 阅70 转1 评0 公众公开 15-10-16 14:45 |
When the runtime environment needs to load a new class for an application, it looks for the class in the following locations, in order:Bootstrap classes: the runtime classes in rt.jar, internationalization classes in i18n.jar, and others.When loading a class, a class loader first "delegates" the search for t... 阅15 转0 评0 公众公开 15-10-16 00:40 |
首先,Java中的getResourceAsStream有以下几种: 1. Class.getResourceAsStream(String path) : path 不以’/''开头时默认是从此类所在的包下取资源,以’/''开头则是从。第二:在me.class目录的子目录下,例如:com.x.y 下有类me.class ,同时在 com.x.y.file 目录下有资源文件myfile.xml.第三:不在me.class目录下,也不在子... 阅10 转0 评0 公众公开 15-08-23 21:27 |