IDEA from zero to proficient (33) IDEA optimized guide package (automatic import package, delete package)

About the Author

Author name: Programming Ming Ming Shiyin
Introduction: CSDN blog expert, has been engaged in software development for many years, proficient in Java, JavaScript, bloggers also learn and grow step by step from scratch, know the importance of learning and accumulation, and like to play with the majority of ADCs Wild Upgrade, welcome your attention, and look forward to learning, growing, and taking off with you!

introduction

I was an old programmer who used eclipse and myeclipse all the time. Many of my fans said they wanted to use ideas and asked me why I didn’t use ideas. I learned more Java knowledge and practiced more, but as a fan fan, how could I refuse the request of fans, so I secretly learned a wave (bring it to you), and then wrote this series, I hope Friends can gain something, Brother Ming will work hard to update.

navigation

✪ IDEA from zero to proficient catalog index◄Previous
[32] IDEA opens and enters the welcome interface
►Next [34] IDEA powerful file comparison function

overview

The optimized package import function can help us automatically delete useless package imports, and automatically import packages that are not imported.
Moreover, when you change the path of the referenced class, it will also automatically change the import path.

set up

  1. The location of the setting: Settings→Editor→General→Auto Import

insert image description here

  1. Tick
    ​​Check add unambiguous imports on the fly and Optimize imports on the fly

Add unambiguous imports on the fly: Quickly add unambiguous imports. [Of course, if there is a package with the same name, you need to manually import it by Alt + Enter]
Optimize imports on the fly: Quickly optimize imports, which means that there are useless packages, which will be automatically deleted for us.
insert image description here


  1. Import Insert imports on paste (I choose All) when pasting the code.
    For example, if we copy a piece of code from the Internet and paste it into our project, we can set whether to import it or not.
    insert image description here
  • All direct import, I like to use this
  • Ask means let us choose by ourselves (this is actually pretty good)
  • None means do nothing

test case

  • Example 1, automatically importing classes

After the input ArrayList is completed, it will be imported automatically

insert image description here

  • Example 2, automatically delete unnecessary imports

Delete the 5th line where the ArrayList is located, it will automatically delete the imported

insert image description here

  • Example 3, the one with the same name cannot be imported automatically, and needs to be imported manually

I want to refer to the java.util.Date class, but it cannot be imported automatically after the input is completed;
because Date has multiple names with the same name;
press the shortcut key alt+enter to select the class to be imported.

insert image description here

  • When changing the path of the referenced class, it will also automatically change the import path

The User class is initially under the vo1 package;
drag the User class to the vo package, and the package path of the import statement will be automatically adjusted in the class.
insert image description here

  • Example 5, paste the code and import it automatically

Paste the code containing the List ArrayList User class and it will be imported automatically.

insert image description here

summary

This section summarizes "IDEA optimization guide package settings", I hope it can be helpful to everyone, please help [Like] + [Favorite] + [Punch in the comment area] , if you are interested in learning Java with Xiao Ming , [Follow a wave] Don't get lost.

Please go to the bottom of the article to help [One-click three links] Thank you!

insert image description here

navigation

✪ IDEA from zero to proficient catalog index◄Previous
[32] IDEA opens and enters the welcome interface
►Next [34] IDEA powerful file comparison function

Popular column recommendation

【1】Java mini-games (Tetris, Plants vs. Zombies, etc.)
2】JavaWeb project combat (library management, dormitory management, etc.)
【3】JavaScript wonderful examples (aircraft wars, verification codes, etc.)
200 cases
[5] Learn Java from zero, learn Java with fun
[6] IDEA from zero to proficient
insert image description here

Guess you like

Origin blog.csdn.net/dkm123456/article/details/123418605