Introduction to Java Foundation Class Library

Source: Internet
Author: User
Tags square root stringbuffer

Introduction to Java Basic class library A common base Class library: 11 Jar (Java Archive,java archive) package

As a Java language user, we can feel the advantages of the Java language (platform-independent, object-oriented, multi-threading, efficient and extensible, etc.), and it has many of the implemented class libraries available for us to use directly, these libraries are in the form of jar packages, can also become Java API, It provides programmers with a variety of common methods of operation, the programmer to write Java program code to bring a lot of convenience.

As a beginner, I think it is necessary to master and apply Java Basic Library. Therefore, some of the basic knowledge points in Java are summarized. The main APIs provided by the Java 2 standard are shown in the following table.

Package Name

Content Overview

Java.applet

Provides the classes required to create applet applets

java.awt

Contains all classes for creating the user interface and drawing graphics images

java.io

Provides classes related to input and output

Java.beans

Contains classes related to developing JavaBeans

Java.lang

Provides the basic class for Java language programming

java.net

Provides classes related to implementing network operations

Java.nio

Classes that provide buffers for input and output

Java.text

provides classes and interfaces for working with text, dates, numbers, and messages

Java.util

Provides classes for working with tools such as date, time, random number generation, etc.

Javax.net

Provides classes, network application extension classes for network applications

Java.swing

Provides a set of pure Java-like component classes with the same AWT functionality

Second, Java.lang bag

The Java.lang package is the foundation of all the other class libraries in the Java language system, embedded in the Java virtual machine, and created as objects, so we don't need to import them using the Java.lang package, we can use all the classes in the Java.lang package directly and reference a The brightness, variables, and operating methods in a class.

Class name

Function

Boolean

Encapsulates a Boolean value and some methods that manipulate the type

Byte

Encapsulates a value of type Byte and some methods for manipulating that type

Character

Encapsulates a value of type char and some methods for manipulating that type

Double

Encapsulates a value of type double and some methods for manipulating that type

Float

Encapsulates a value of type float and some methods for manipulating that type

Integer

Encapsulates a value of type int and some methods for manipulating that type

Long

Encapsulates a long value and some methods for manipulating that type

Short

Encapsulates a value of type short and some methods for manipulating that type

String

Encapsulates the action method associated with a string type

Void

Represents the declaration of the Void keyword in Java, which is not available as an instance

Class

Used to describe the state of classes and interfaces in a running Java application

ClassLoader

The object used to load the class

Enum

Used to define enum types

Math

Used to implement basic mathematical operations

Number

Abstract class, which is the parent class of the basic data type class

Object

is the root class of all Java classes

Package

Encapsulates version information about the implementation and specification of Java packages

Runtime

The runtime class object connects the Java application to its running environment

Strictmath

Used to implement basic mathematical operations

StringBuffer

Operations for variable strings

StringBuilder

Creating a mutable String Object

System

Encapsulates some of the methods associated with Java Virtual machine systems

Thread

Creating and controlling threads

Threadgroup

Creating and controlling thread groups

Throwable

A parent class that defines all errors or exceptions in Java

Process

Defines a process processing object that starts the process object through the Exec method in the runtime class

The main interfaces defined in the Java.lang package and their corresponding function descriptions are shown in the following table:

Interface

Function

Appendable

Used to append strings

Cloneable

For copying class objects

Runnable

Used to implement a class object that has threading capabilities

Comparable

Sorting for Class objects

2.Object class Description

The object class is the parent of all classes in the Java system, that is, the class objects created in a program developed in the Java language are derived from the object class and either implement or inherit the methods in the object class.

The jar package encapsulates constants, variables, and methods that, when a class object is created, can directly reference constants and variables in the object, specify the input parameters of the method when invoking the method in the object, and provide the method with data and return values that conform to the parameter type, and whether the method will produce an exception when called. If the method can produce an exception, you need to use the TRY-CATCH statement structure to catch and handle the exception, or use the Java keyword throws to throw a possible exception.

3.Java Basic data types

The basic data types specified in the Java language include 8 Boolean, Byte, character, double, float, integer, long, short, and so on. Through these constants, variables that can declare the base data type. However, because Java is a purely object-oriented programming language, in order to implement object-oriented, Java.lang defines the corresponding classes for these basic data types (variable types that encapsulate the basic data types, variables-related constants, and related operating methods). This allows you to use these basic types of values or variables as object handling.

The number abstract data type is also defined in the Java.lang package, specifically for operations of a purely numeric object, including integers and floating-point types in the base data type for pure numeric objects. It is clear that the number class is the direct parent of integer and floating-point types, and defines an action method and an abstract method that applies to the pure numbers of different data types in the # class.

(Description: The character class encapsulates a numeric value of type char and the associated operation method, all of which are encoded in Unicode standard characters)

4. String Class String&stringbuffer

The string class for handling strings is also provided in Java.lang, which is used to handle "immutable" strings, and the StringBuffer class is also provided to handle "mutable" strings. Both the Stirng class and the StringBuffer class are declared as final types, so they cannot be inherited as a parent class.

(1) String class

The string class is used to create strings, whose values are treated as constants after they are created, and the string class encapsulates the numeric value of the type and the associated operation method. All action methods in the string class are for a string object that has already been created, and the string object is created through the constructor of the string class.

(2) StringBuffer class

The StringBuffer class is a string buffer class used to create variable-length string objects, where "variable length" means that the length and content of a string can be changed by invoking some method, for example, by appending a new string sequence on the basis of the original string. or insert a new character sequence at a location on the original string, and so on to form a new string object.

The StringBuffer class creates a string object based on a new buffer implementation that holds the character sequence of the string in the buffer, because the buffer has a certain capacity, so when the length of the string changes, if the buffer overflow occurs, The Java runtime expands the buffer capacity created by the StringBuffer object itself, guaranteeing the security of string operations.

5.Math class

Arithmetic operations of various data types are encapsulated in the math class, which includes operations such as exponential, logarithmic, square root, trigonometric functions, and so on. All of its constants and methods are defined as static in the math class, so all members can be referenced directly.

6.Runtime class

The runtime class encapsulates a number of Java virtual machine-related methods that create a runtime object when a Java virtual machine launches each Java application, which guarantees a connection between the Java application and its running environment, after the runtime object is created, The methods defined in the runtime class can be called directly in a Java application (for example, getting run information for the current program, exiting the program, shutting down the Java virtual machine, and so on).

7.System class

The system class encapsulates some constants related to computer input/output systems, as well as how to operate with Java virtual machines. After the Java virtual machine is started, the system object is created and the system object cannot be created in the Java application. All constants and methods in the system class are defined as static, so the constants and methods defined inside the system class can be called directly in a Java application.

8. Summary

There are a lot of available class libraries for the Java language, which brings a lot of convenience to the programmer, and you need to review the help documentation and instructions to determine the functionality when you use it. The key concerns are the input parameters, return values, exceptions, and so on for an action method.

Introduction to Java Foundation Class Library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.