How to set up the idea automatic package

Mondo Technology Updated on 2024-01-31

There are several ways to automate the import of packages in IntelliJ Idea:

1.Enter the short name of the class you want to use in the editor (i.e. the name of the class that does not include the package name).

2.If IDEA detects that the class is not in the list of imported classes, it highlights the name of the class in the editor.

3.Place the cursor over the class name, press the Alt + Enter shortcut, and then select Import'Class name'option.

4.If you use certain classes a lot, add them to the compiler-level auto-import list so that they are automatically imported into each new file:

Open the Idea Settings window.

In the left panel, expand the "Editor" and "General" groups and select the "Auto Import" option.

Under the "Auto Import" tab, find the "J**A" section.

Click the "+" button on the right to add the package name of the class you use frequently. In the Class and Package columns, enter the class name and package name that you want to import. You can also specify the source where the imported class is located, such as JDK, etc.

Now, when you start writing a new ja, the editor will automatically import all the packages and classes you specify. If you have any problems writing the **, you can get more help by checking out the official documentation of IDEA or through IDEA's official support channels.

Related Pages