Home  >  Article  >  Java  >  What are the packages automatically imported by the compiler in Java?

What are the packages automatically imported by the compiler in Java?

下次还敢
下次还敢Original
2024-04-26 20:45:191071browse

The Java compiler automatically imports the following packages: java.langjava.utiljava.iojava.mathjava.netjava.sql, java.awt, and java.swing need to be imported explicitly.

What are the packages automatically imported by the compiler in Java?

Packages automatically imported by the Java compiler

The Java compiler provides an automatic import function so that developers can You don't have to explicitly import common packages when writing code. The following lists the packages automatically imported by the Java compiler:

  • java.lang

    • Contains the basic classes and interfaces of the Java language , such as Object, String, Thread, etc.
  • java.util

    • Contains classes and interfaces for data structures such as collections, maps, lists, etc.
  • java.io

    • Contains classes and interfaces for file and stream input/output.
  • java.math

    • Contains classes and interfaces for large number calculations.
  • java.net

    • Contains classes and interfaces for network connectivity and communication.
  • java.sql

    • Contains classes and interfaces for accessing and manipulating the database (explicit import required) .
  • java.awt

    • Contains classes and interfaces for graphical user interface (GUI) programming (requires display import).
  • java.swing

    • Contains classes and interfaces for advanced GUI programming (requires explicit import).

The above is the detailed content of What are the packages automatically imported by the compiler in Java?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn