Java程序设计的常用类.docx

上传人:b****5 文档编号:3989433 上传时间:2022-11-27 格式:DOCX 页数:39 大小:55.14KB
下载 相关 举报
Java程序设计的常用类.docx_第1页
第1页 / 共39页
Java程序设计的常用类.docx_第2页
第2页 / 共39页
Java程序设计的常用类.docx_第3页
第3页 / 共39页
Java程序设计的常用类.docx_第4页
第4页 / 共39页
Java程序设计的常用类.docx_第5页
第5页 / 共39页
点击查看更多>>
下载资源
资源描述

Java程序设计的常用类.docx

《Java程序设计的常用类.docx》由会员分享,可在线阅读,更多相关《Java程序设计的常用类.docx(39页珍藏版)》请在冰豆网上搜索。

Java程序设计的常用类.docx

Java程序设计的常用类

Java程序设计的常用类

一.常用类的继承关系

1.异常处理的类继承关系

Object

-----------Throwable

---------Error

----------LinkageError

---------VirtualMachineError

---------AWTError

---------Exception

----------RuntimeException

-----------ArithmeticException

-----------IndexOutofBoundsException

-----------InterrupedException

----------IOException

----------FileNotFoundException

----------EOFException

----------CharConversionException

----------AWTException

----------ClassNotFoundException

……….

2.I/O类的继承关系

java.lang.object

------File

------InputStream(抽象类)

--------ObjectInputStream

---------FileInputStream(基于字节的文件I/O)

--------FilterInputStream(提供更多功能的抽象类)

----------DataInputStream

----------BufferedInputStream(提高I/O性能)

-------OutputStream(抽象类)

--------ObjectOutputStream

---------FileOutputStream

--------FilterOutputStream

----------DataOutputStream

----------BufferedOutputStream

----------PrintStream

-------RandomAccessFile

-------Reader(抽象类)

---------InputStreamReader(将字节流转换为字符流)

----------FileReader(从文件中读入字符)

---------BufferedReader(提高I/O性能,按行读取)

----------LineNumberReader(可获取行号)

--------Writer(抽象类)

--------OutputStreamWriter

----------FileWriter

---------BufferedWriter

---------PrintWriter

-------Scanner

--------System三个静态对象:

publicstaticPrintStreamerr;//标准错误

publicstaticPrintStreamout;//标准输出

publicstaticInputStreamin;//标准输入

3.图形用户界面的类的继承关系

 

Object

--------Componet

--------Container

-------Window

----------Frame

----------JFrame

----------Dialog

----------FileDialog

----------JDialog

-------ScrollPane

-------Panel

----------Applet

---------JApplet

-------Javax.Swing.Jcomponent

--------AbstractButton

------JButton

------JMenuItem

------JToggleButton

-------JRadioButton

-------JCheckBox

--------JComboBox

--------JLabel

--------JList

--------JMenuBar

--------JPanel

--------JScrollBar

--------JTextComponet

-------JTextArea

-------JTextField

--------JPasswordField

--------JScrollPane

-------JOptionPane

-------JTable

-------JLayeredPane

-------JDesktopPane

-------JInternalFrame

--------Button

--------Label

--------CheckBox

--------Scrollbar

--------List

--------Canvas

-------TextComponet

-------TextField

-------TextArea

 

-------AbstractTableModel

---------DefaultTableModel

-------CheckboxGroup

-------Image

----------BufferedImage

-------ImageIcon

-------ToolKit

-------Color

-------EventObject

---------AWTEvent

---------ActionEvent

---------ComponentEvent

-------------FocusEvent

------------InputEvent

------------MouseEvent

------------KeyEvent

-----------WindowEvent

---------AdjustmentEvent

---------ItemEvent

----------ListSelectionEvent

-------Font

------Graphics

------FlowLayout

------BorderLayout

------BoxLayout

------GridLayout

------GridBagLayout

------CardLayout

------MenuComponet

----------MenuItem

---------Menu

----------PopupMenu

---------CheckBoxMenuItem

----------MenuBar

-----ComponentAdapter

-----FocusAdapter

-----KeyAdapter

-----MouseAdapter

-----MouseMotionAdapter

-----WindowAdapter

-----MemoryImageSource

-----FilteredImageSource

-----ImageFilter

-----ImageIO

二、包java.lang(自动引入)

1.String类:

(1).构造函数:

publicString() 构造一个空串

publicString(char[]value,intoffset,intcount)根据一个字符数组构造一个非空串

(2).publicintlength()字符串长度

(3).publiccharcharAt(intindex)返回index处字符

(4).publicintindexOf(intch)返回ch在串中的第一次出现的位置

(5).publicvoidgetChars(intsrcBegin,intsrcEnd,char[]dst,intdstBegin)

从当前字符串中拷贝若干字符到字符数组dst[]

(6).publicStringconcat(Stringstr)当前对象与str连接起来

(7).publicStringreplace(charoldChar,charnewChar)用新字符替换旧字符

(8).publicStringsubstring(intbeginIndex)

publicStringsubstring(intbeginIndex,intendIndex)取子串

(9).publicStringtoLowerCase()变小写

(10).publicStringtoUpperCase()变大写

(11).publicbooleanendsWith(Stringsuffix)

如果suffix所表示的字符串是当前字符串对象的后缀,返回true,否则false

(12).publicbooleanequals(ObjectanObject)

当当前对象与字符串对象anObject表示相同的字符串时,返回true,否则false

(13).publicstaticStringvalueOf(inti)整型值转为字符串

(14).publicstaticStringvalueOf(floatf)浮点数转为字符串

2.StringBuffer类

(1).构造函数:

publicStringBuffer()构造一个空串缓冲区,长度为16

publicStringBuffer(intlength)构造一个长度为length缓冲区

publicStringBuffer(Stringstr)构造一个缓冲区,初始化为str

(2).publicintlength()返回字符串缓冲区包含的字符数

(3).publiccharcharAt(intindex)返回index处字符

(4).publicvoidgetChars(intsrcBegin,intsrcEnd,char[]dst,intdstBegin)

从当前字符串中拷贝若干字符到字符数组dst[]

(5).publicintcapacity()返回缓冲区的容量.

(6).publicsynchronizedStringBufferappend(Stringstr)在已有串尾添加一个串str

(7).publicsynchronizedStringBufferinsert(intoffset,Stringstr)在offset处插入字符串str

3.类Integer

(1).构造方法:

publicInteger(intvalue)构造整数对象

(2).publicintintValue()返回Integer对象对应的整数值

(3).publicstaticIntegervalueOf(Strings)throwsNumberFormayException

根据s构造一个Integer对象返回

(4)publicstaticintparseInt(Strings)throwsNumberFormatException

4.类System

(1).成员变量:

staticPrintStreamerr;

staticInputStreamin;

staticPrintStreamout;

(2).publicstaticvoidexit(intstatus)终止当前正在运行的JAVA虚拟机

5.类Thread

(1).构造方法:

publicThread(ThreadGroupgroup,Runnabletarget,Stringname)

publicThread(Runnabletarget,Stringname)

publicThread(Stringname)

(2).publicstaticThreadcurrentThread()返回当前正在执行的线程

(3).publicfinalStringgetName()返回当前线程的名字

(4).publicfinalintgetPriority()返回当前线程的优先数

(5).publicfinalbooleanisAlive()当前线程是否处于活动状态

(6).publicfinalvoidjoin()throwsInterruptedException等待当前线程进入死亡状态

(7).publicvoidrun()定义线程体

(8).publicfinalvoidsetPriority(intnewPriority)改变线程优先级

(9).publicstaticvoidsleep(longmillions)throwsInterruptedException当前正在执行的线程休眠

(10).publicvoidstart()启动线程

(11).publicstaticvoidyield()暂停当前正在执行线程的执行

(12).voidstop()结束当前进程

6.类Object

(1).publicfinalvoidwait()throwsInterruptedException

使当前线程处于等待状态

(2).publicfinalvoidnotify()

唤醒线程

7.类Throwable

(1).publicvoidprintStackTrace()打印调用栈内容

8.类Error

9.类Exception

10.类ThreadGroup

(1).publicThreadGroup(Stringname)

11.类Class

(1).publicstaticClass

>forName(String className)throwsClassNotFoundException

三、包java.io

1.抽象类InputStream

(1).publicvoidclose()throwsIOException关闭输入流

(2).publicabstractintread()throwsIOException从输入流读入一个字节,返回字节值.若遇到流尾,返回-1

(3).publicintread(byte[]b,intoff,intlen)throwsIOException

从输入流中尽可能读len个字节到数组b,放在off起始处开始的位置.返回实际读取的字节数.若遇到流尾,返回-1

2.抽象类OutputStream

(1).publicvoidclose()throwsIOException关闭输出流

(2).publicabstractvoidwrite(intb)throwsIOException

向输出流写出一个字节,即b的低8位.

(3).publicvoidwrite(byte[]b,intoff,intlen)throwsIOException

向输出流写数组b的off起始处len个字节.

(4).publicvoidflushthrowsIOException清空输出流

3.类File

(1).构造方法:

publicFile(Stringpath);

publicFile(Stringpath,Stringname)

(2).publicbooleandelete()删除文件

(3).publicbooleanisFile()是否文件

(4).publicString[]list()返回目录的文件及子目录

(5).publicString[]list(FilenameFilterfilter)返回目录中符合过滤器的文件及子目录

4.接口FilenameFilter

(1).publicbooleanaccept(Filedir,Stringname)

检测指定的文件是否包含于文件列表.当包含于文件列表时,返回true,否则false.

5.类FileInputStream

(1).构造方法:

publicFileInputStream(Stringname)throwsFileNotFoundException

publicFileInputStream(Filefile)throwsFileNotFoundException

(2).publicvoidclose()throwsIOException关闭输入流

(3).publicintread()throwsIOException

从输入流读入一个字节,返回字节值.若遇到流尾,返回-1

(4).publicintread(byte[]b,intoff,intlen)throwsIOException

从输入流中尽可能读len个字节到数组b,放在off起始处开始的位置.返回实际读取的字节数.若遇到流尾,返回-1

6.类FileOutputStream

(1).构造方法:

publicFileOutputStream(Stringname)throwsFileNotFoundException

publicFileOutputStream(Filefile)throwsIOException

(2).publicvoidclose()throwsIOException关闭输出流

(3).publicvoidwrite(intb)throwsIOException

向输出流写出一个字节,即b的低8位.

(4).publicvoidwrite(byte[]b,intoff,intlen)throwsIOException

向输出流写数组b的off起始处len个字节.

(5)voidclose()关闭文件

7.类RandomAccessFile

(1).构造方法:

publicRandomAccessFile(Stringname,Stringmode)throwsFileNotFoundException

mode取值”r”指打开文件用于输入

mode取值”rw”指打开文件用于输入及输出

(2).publiclonggetFilePointer()throwsIOException

获取文件当前偏移量

(3).publicvoidseek(longpos)throwsIOException

文件指针移到pos处

8.接口DataInput

(1).publicbooleanreadBoolean()throwsIOException

读取一个输入字节,当这个字节非0时为真,否则为0.适合读DataOutput接口的writeBoolean方法写入的值.

(2).publicbytereadByte()throwsIOException

读并返回一个输入的字节.适合读DataOutput接口的writeByte方法写入的值.

(3).publiccharreadChar()throwsIOException

读并返回一个输入的字符.适合读DataOutput接口的writeChar方法写入的值.

(4).publicdoublereadDouble()throwsIOException

读并返回一个输入的double值.适合读DataOutput接口的writeDouble方法写入的值.

(5).publicfloatreadFloat()throwsIOException

读并返回一个float值.适合读DataOutput接口的writeFloat方法写入的值.

(6).publicintreadInt()throwsIOException

读并返回一个int值.适合读DataOutput接口的writeInt方法写入的值.

(7).publicStringreadLine()throwsIOException

读入一行文本.如果在读第一个字节之前就遇到文件尾,将返回空.

(8).publiclongreadLong()throwsIOException

读并返回一个long值.适合读DataOutput接口的writeLong方法写入的值.

(9).publicshortreadShort()throwsIOException

读并返回一个short值.适合读DataOutput接口的writeShort方法写入的值.

(10).publicStringreadUTF()throwsIOException

从一个以UTF-8格式记录的字符串中读取.适合读DataOutput接口的writeUTF方法写入的数据.

9.接口DataOutput

(1).publicvoidwriteBoolean(booleanv)throwsIOException

将一个boolean值写入输出流.

(2).publicvoidwriteByte(intv)throwsIOException

将v的低8位写入输出流.

(3).publicvoidwriteChar(intv)throwsIOException

写一个char类型值到输出流.此值包含2个字节.

(4).publicvoidwriteDouble(doublev)throwsIOException

写一个double类型值到输出流.

(5).publicvoidwriteFloat(floatv)throwsIOException

写一个float类型值到输出流.

(6).publicvoidwriteInt()throwsIOException

写一个int类型值到输出流.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 数学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1