官术网_书友最值得收藏!

Managing projects

On the left side of the IDE window, you can see the directory structure of the project. The IDE knows the different types of files and shows them in a way that is meaningful from the programming point of view. For example, it does not display Main.java as a filename. Instead, it displays Main and an icon that signals that Main is a class. It can also be an interface still in a file named Main.java but, in that case, the icon will show that this is an interface. This is again done by the IDE continuously scanning and compiling the code.

The files are structured into subdirectories when we develop a Java code. These subdirectories follow the packaging structure of the code. Many times, in Java, we use compound and long package names, and displaying it as a deep and nested directory structure will not be so easy to handle.

Packages are used to group the source files. The source files for classes that are related in some way should go into one package. We will discuss the notion of packages and how to use them in the next chapter

The IDE is capable of showing the package structure instead of the nested directories for those directories of the project that contain source files.

When you move a class or an interface from one package to another, it happens in a similar way as renaming or other refactoring. All references to the class or interface in the source files get renamed to the new package. If a file contains an import statement referring to the class, the name of the class in the statement is corrected. To move a class, you can open the package and use the good old drag and drop.

Package hierarchy is not the only hierarchy displayed in the IDE. The classes are in packages but, at the same time, there is an inheritance hierarchy. Classes may implement interfaces and can extend other classes. The Java IDEs help us by showing type hierarchies where you can navigate across a graphical interface along the inheritance relations.

There is another hierarchy that IDEs can show to help us with development: method call hierarchy. After analyzing the code, the IDE can show us the graph displaying the relations between the methods: which method calls which other methods. Sometimes, this call graph is also important in showing the dependencies of methods on each other.

主站蜘蛛池模板: 门源| 泰和县| 时尚| 广西| 呈贡县| 会泽县| 利川市| 凤城市| 东乌| 定远县| 天水市| 永顺县| 灌云县| 喜德县| 怀仁县| 喜德县| 弥勒县| 桓仁| 辽阳市| 辉南县| 胶南市| 南华县| 磴口县| 永川市| 菏泽市| 叙永县| 永城市| 崇文区| 正镶白旗| 黎川县| 南雄市| 进贤县| 仪征市| 曲阳县| 延边| 永胜县| 大安市| 米泉市| 江安县| 都匀市| 光泽县|