Java JDK commonly used packages and classes and methods in the package: java.lang package

java.lang: 

    The java.lang package is the foundation of all other class libraries in the java language system. It has been embedded in the java virtual machine and created in the form of objects. Therefore, we do not need to use import when using the java.lang package. Its import can directly use all the classes in the java.lang package and directly refer to the exposure, variables and operation methods in a class.

class name

Function

Boolean

Encapsulates the value of the boolean type and some methods for manipulating the type

Byte

Encapsulates the value of byte type and some methods for manipulating this type

Character

Encapsulates the value of char type and some methods for manipulating this type

Double

Encapsulates the value of type double and some methods for manipulating this type

Float

Encapsulates the value of float type and some methods for manipulating this type

Integer

Encapsulates the value of type int and some methods for manipulating this type

Long

Encapsulates the value of type long and some methods for manipulating this type

Short

Encapsulates the value of type short and some methods for manipulating this type

String

Encapsulates the operation methods related to the string type

Void

Represents a declaration of the void keyword in Java , this class cannot be instantiated

Class

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

ClassLoader

object used to load the class

Enum

Used to define enumeration types

Math

Used to implement basic math 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 the java package

Runtime

The Runtime class object connects a java application to its runtime environment

StrictMath

Used to implement basic mathematical operations

StringBuffer

Operations on mutable strings

StringBuilder

Create mutable string objects

System

Encapsulates some methods related to the java virtual machine system

Thread

Create and control threads

ThreadGroup

Create and control thread groups

Throwable

Defines the parent class of all errors or exceptions in java

Process

Define a process process object and start the process object through the exec method in the Runtime class


interface:

interface

Function

Appendable

for appending strings

Cloneable

for copying class objects

Runnable

Used to implement class objects with threading capabilities

Comparable

Sorting for class objects


1.字符串类String和StringBuffer

  1.1.String类

 String类用于创建字符串对象,其值在创建之后被当做常量,String类里面还封装了字符串类型的数值以及相关的操作方法。String类中的所有操作方法都是针对已经创建的String对象而言的,而String对象是通过String类的构造函数创建的。

 常用方法:

string.charAt(index) 获取字符串指定索引处的字符                                                              
string.compareToIgnoreCase(str); 忽略大小写比较两个字符串内容
string.endsWith(suffix); 判断是否以指定字符串结尾
string.equals(anObject); 判断两个字符串是否相等
string.indexOf(str); 获取指定字符串的索引
string.isEmpty(); 判断字符串是否为空
string.length(); 获取字符串长度
string.matches(regex); 判断字符串是否符合正则表达式规则
string.toUpperCase(); 将字符串全部转化为大写
string.substring(beginIndex, endIndex); 截取指定位置的字符串
string.split(str); 根据要求分割字符串,返回分割后的字符串数组
string.replace(oldChar, newChar); 将字符串中指定字符替换为新的字符

  1.2.StringBuffer   

    StringBuffer类是字符串缓冲区类,用于创建长度可变的字符串对象,这里的“长度可变”是指通过某些方法的调用可以改变字符串的长度和内容,比如通过在原字符串的基础上追加新的字符串序列,或者在原字符串的某个位置上插入新的字符序列等构成新的字符串对象。

  SingBuffer类创建字符串对象是基于开辟新的缓冲区实现的,在缓冲区中存放字符串的字符序列,因为缓冲区是有一定容量的,所以当字符串长度改变的之后,如果超过了缓冲区的容量时,即发生缓冲区溢出时,java运行系统会自行扩大StringBuffer对象创建的缓冲区容量,保证了对字符串操作的安全性。

常用方法:

buffer.append(str); 给字符串添加新的字符串                                
buffer.delete(start, end); 删除指定位置的字符串
buffer.insert(offset, str); 在指定位置插入字符串
buffer.reverse(); 反转字符串

2.Math类:

Math类中封装了各种数据类型的算术操作,即包含了指数、对数、平方根、三角函数等操作。在math类中其所有的常量和方法都被定义为静态的,因此所有的成员都可以直接被引用。

详情请参考:java Math常用方法总结


Guess you like

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