From the course: Java 25 for Professionals with Jetbrains AI Assistant
Modernizing Java projects with simplified module imports - Java Tutorial
From the course: Java 25 for Professionals with Jetbrains AI Assistant
Modernizing Java projects with simplified module imports
- [Instructor] Here's a lovely import mess. As you can see, I'm importing all these classes and they're all being used by this code. Not saying this is the most useful of code, but it's using all these classes. Well, welcome to the new Java. We can replace all of this by saying import module_java.base. That's 14 imports replaced by one line. So, a question I had, doesn't this make my app bigger? But no, it doesn't. The import is just compile time only. At runtime, imports are not carried into the class files, and the byte code contains the full class references, not the import statements. Import modules just lets you avoid rising repetitive import lines, but luckily, it doesn't increase the dependency graph or the size of your deliverable.