We all know that this IDEA development tool very easy to use, very much, today, when reviewing a set of Java system, want to see the inheritance structure of a class or interface, and then search for a wave, are using the IDEA Diagram plug , here to share.
For example, I wrote this piece of code
public class CollectionLearning {
public static void main(String[] args) {
List list = new ArrayList();
list.add("java");
list.add("Android");
list.add("python");
list.add("前端");
//lambda+方法引用:遍历list集合元素
list.forEach(System.out::println);
}
}
Then I want to see the inheritance structure ArrayList, we can right-click on the ArrayList class, in the pop-up dialog box, select Diagram.
Displays two options:
Show Diagram ... -> display class inheritance structure diagram in a new tab
Show Diagram Popup ... -> elastic layer displayed in the current page class inheritance structure diagram
still feel good display in a new tab, we'll see ArrayList to the inheritance structure diagram of
this view is very clear, sometimes I feel that the relationship has displayed all the class or interface takes up too much screen, we can not delete a class or interface concerned, 鼠标点击某个类或接口,按住delete键就会删除它。
we removed the Cloneable, Serializable, RandomAccess interfaces, we note that there are different colors and arrows on top of the actual situation, these lines are marked relationship between class and class, classes and interfaces.
蓝色实线箭头:类之间继承
绿色实线箭头:接口之间继承
绿色虚线箭头:类实现接口
Sometimes just look at the class inheritance structure diagram is not enough, we also want to methods in the class, variables, constructors, and so on.
We can right-click on the current page
in the figure above, we can choose to display variables, constructors, methods, properties, inner classes. We click on Fileds
so we show the class or interface variables involved in the inheritance structure diagram, we click constructor
this constructor will all show up for this we would like to quickly understand the internal structure of a class of very fast, we the above operations can also be done using the Quick toolbar.
We can also quickly access to the source code which variable or method. We double-click a class or interface, in which the mouse will then walk, then we have to choose a method Jump to Source, you can enter the source of which
we sometimes feel relatively small figure shows, not clear, we You can use the magnifying glass function,
按住Alt键,鼠标移到哪就是放大镜。
sometimes we would like to see the current class and other classes if a relationship, we'll add other classes come in,
right-click to select Add Class to Diagram...
a dialog box
us in class in the class's name, press enter. Here I enter the Map interface
so that we know ArrayList and Map does not matter (There may be superfluous, already shows all the current class inheritance structure diagram)