IDEA查看JDK源码
2022-09-22 22:43:34

查看源码时,IDEA默认是反编译的文件。并没有源码的注释,和参数变量名。

比如List:

1
2
3
4
5
6
public interface List<E> extends Collection<E> {

int size();
isEmpty();
...
}

解决方法

File -> Project Structure -> SDKs -> SourcePath -> 导入JDK中src.zip压缩包

image.png

image.png

再次查看源码,已经带有注释,方便我们理解代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

public interface List<E> extends Collection<E> {
// Query Operations

/**
* Returns the number of elements in this list. If this list contains
* more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this list
*/
int size();

/**
* Returns <tt>true</tt> if this list contains no elements.
*
* @return <tt>true</tt> if this list contains no elements
*/
boolean isEmpty();
}
Prev
2022-09-22 22:43:34
Next