Commonly used JDK packages

All standard Java classes provided by JDK are stored in Java packages. For example, the java.lang package contains system classes that are essential for running Java. Since the system will automatically import java.lang, there is no need to explicitly import this package with an import statement in the source file. In addition, Java kneeling over java.util and java.io are standard packages that must be provided. The commonly used packages in JDK are as follows:

1.java.lang: language package

2.java.util: utility package

3.java.awt: Abstract Window Toolkit

4.javax.swing: A lightweight window toolkit, which is currently the most widely used GUI programming package

5.java.io: input and output package

6.java.net: network function package

7.java.applet: The package used for compiling applet (currently, when compiling applet programs, more JApplet classes in swing are used).

These packages are described below:

①.java.lang: language package

This is the core package of the Java language. The system automatically introduces this package into the user program. The main classes in this package are:

1.Object class: It is the parent class of all classes, and the methods defined in it can be used by other classes.

2. Data type wrapper class: class wrapper for simple data types, including Integer, Float, Boolean, etc.

3. Math Math: Provides constants and mathematical functions, including E and PI constants and methods such as abs(), sin(), cos(), min(), max(), random(), etc. These constants and methods are still.

4. String class String and StringBuffer class.

5. System and runtime classes: The System class provides a programming interface independent of specific computer system resources; the Runtime class can directly access runtime resources.

6. Operation class: Class and ClassLoader class. The class Class provides some information about the object at runtime. ClassLoader is an abstract class that provides a method to convert the class name into a file name and find and load the file in the file system.

7. Thread class: Thread class. Java is a multi-threaded environment, mainly including Thread (thread establishment), ThreadDeath (cleaning operation after the thread ends), ThreadGroup (organizing a group of threads) and Runnable (interactive tool for establishing threads).

8. Error and exception handling classes: Throwable (the parent class for all error and exception handling), Exception (handling exceptions, requiring user catch handling) and Error (handling hardware errors, not requiring user catch handling).

9. Process class Process: It supports system processes. When the utility class Runtime executes system commands, it will create a Process class that handles system processes.

②.Utility bag

The utility package provides classes with various practical functions, mainly including date classes, data structure classes, and random number classes.

1. Date class: including Date (get date and time), Calendar (abstract class, calendar class) and GregorianCalendar (subclass of Calendar class) classes.

2. Data structure class: including linked list class LinkedList, vector class Vector, stack class Stack and hash table class Hashtable, etc.

3. Random number class Random: It encapsulates the random method in the Math class and provides more auxiliary functions.

③Abstract Window Toolkit

Java's java.awt provides drawing and image classes, which are mainly used to write GUI programs, including common components such as buttons and labels, and corresponding event classes.

1. Component class: including Button, Panel, Label, Choice and other classes, used to design graphical interfaces.

2 Event package: includes interfaces and classes for various event processing in java.awt.event

3. Color package: Provides classes for color in java.awt.color.

4. Font package: provide font-related interfaces and classes in java.awt.font.

④Input and output package

java.io provides system input and output classes and interfaces. As long as the input stream class InputStream and the output stream OutputStream are included, the functions of file input and output, pipeline data transmission and network data transmission can be realized.

⑤Network function package

java.net provides classes for implementing network applications, mainly including the Socket class for implementing Socket communication, and also provides classes for handling URLs

⑥ applet package

java.applet是专为创建Applet程序提供的包,它包含了基本的applet类和通信类,目前基本上被JApplet类所代替。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325945837&siteId=291194637