javaAPI

1.java API(Java Application Interface)是java的应用程序接口。


2.java.lang包:主要含有与语言相关的类。


3.java.io包:主要含有与输入/输出相关的类。


4.java.util包:包括许多具有特定功能的类,有日期、向量、哈希表、堆栈等,其中Date类支持与时间有关的操作。


5.java.swing包和java.awt包:提供了创建图形用户界面元素的类。


6.java.net包:含有与网络操作相关的类,如TCP Sockets、URL等。


7.java.applet包:含有控制HTML文档格式、应用程序中的声音等资源的类。


8.java.beans包:定义了应用编程接口(API),Java Beans是java应用程序环境的中性平台组件结构。




9.Object类常用方法
  protected  Object clone() 
          创建并返回此对象的一个副本。 
  boolean equals(Object obj) 
          指示其他某个对象是否与此对象“相等”。 
  protected  void finalize() 
          当垃圾回收器确定不存在对该对象的更多引用时,由对象的垃圾回收器调用此方法。 
  public final Class getClass() 
          返回此 Object 的运行时类。 
  int hashCode() 
          返回该对象的哈希码值。 
  void notify() 
          唤醒在此对象监视器上等待的单个线程。 
  void notifyAll() 
          唤醒在此对象监视器上等待的所有线程。 
  String toString() 
          返回该对象的字符串表示。 
  void wait() 
          在其他线程调用此对象的 notify() 方法或 notifyAll() 方法前,导致当前线程等待。 
  void wait(long timeout) 
          在其他线程调用此对象的 notify() 方法或 notifyAll() 方法,或者超过指定的时间量前,导致当前线程等待。 
  void wait(long timeout, int nanos) 
          在其他线程调用此对象的 notify() 方法或 notifyAll() 方法,或者其他某个线程中断当前线程,或者已超过某个实际时间量前,导致当前线程等待。


  注意:Object类的equals方法用来比较两个对象是否相等,实现对象上相等差别可能性最大的相等关系。对于任何非空引用值X和Y,当且仅当X和Y引用同一对象时,才返回true。


10. String 对类所包含的字符串内容永远不会被改变;StringBuffer对象所包含的字符串内容可以被添加或修改。


11.string 类常用构造方法
String() 
          初始化一个新创建的 String 对象,使其表示一个空字符序列。 
String(byte[] bytes) 
          通过使用平台的默认字符集解码指定的 byte 数组,构造一个新的 String。 
String(byte[] bytes, Charset charset) 
          通过使用指定的 charset 解码指定的 byte 数组,构造一个新的 String。 
String(byte[] ascii, int hibyte) 
          已过时。 该方法无法将字节正确地转换为字符。从 JDK 1.1 开始,完成该转换的首选方法是使用带有 Charset、字符集名称,或使用平台默认字符集的 String 构造方法。 
String(byte[] bytes, int offset, int length) 
          通过使用平台的默认字符集解码指定的 byte 子数组,构造一个新的 String。 
String(byte[] bytes, int offset, int length, Charset charset) 
          通过使用指定的 charset 解码指定的 byte 子数组,构造一个新的 String。 
String(byte[] ascii, int hibyte, int offset, int count) 
          已过时。 该方法无法将字节正确地转换为字符。从 JDK 1.1 开始,完成该转换的首选方法是使用带有 Charset、字符集名称,或使用平台默认字符集的 String 构造方法。 
String(byte[] bytes, int offset, int length, String charsetName) 
          通过使用指定的字符集解码指定的 byte 子数组,构造一个新的 String。 
String(byte[] bytes, String charsetName) 
          通过使用指定的 charset 解码指定的 byte 数组,构造一个新的 String。 
String(char[] value) 
          分配一个新的 String,使其表示字符数组参数中当前包含的字符序列。 
String(char[] value, int offset, int count) 
          分配一个新的 String,它包含取自字符数组参数一个子数组的字符。 
String(int[] codePoints, int offset, int count) 
          分配一个新的 String,它包含 Unicode 代码点数组参数一个子数组的字符。 
String(String original) 
          初始化一个新创建的 String 对象,使其表示一个与参数相同的字符序列;换句话说,新创建的字符串是该参数字符串的副本。 
String(StringBuffer buffer) 
          分配一个新的字符串,它包含字符串缓冲区参数中当前包含的字符序列。 
String(StringBuilder builder) 
          分配一个新的字符串,它包含字符串生成器参数中当前包含的字符序列。 




12.String 类常用方法
 char charAt(int index) 
          返回指定索引处的 char 值。 
 int codePointAt(int index) 
          返回指定索引处的字符(Unicode 代码点)。 
 int codePointBefore(int index) 
          返回指定索引之前的字符(Unicode 代码点)。 
 int codePointCount(int beginIndex, int endIndex) 
          返回此 String 的指定文本范围中的 Unicode 代码点数。 
 int compareTo(String anotherString) 
          按字典顺序比较两个字符串。 
 int compareToIgnoreCase(String str) 
          按字典顺序比较两个字符串,不考虑大小写。 
 String concat(String str) 
          将指定字符串连接到此字符串的结尾。 
 boolean contains(CharSequence s) 
          当且仅当此字符串包含指定的 char 值序列时,返回 true。 
 boolean contentEquals(CharSequence cs) 
          将此字符串与指定的 CharSequence 比较。 
 boolean contentEquals(StringBuffer sb) 
          将此字符串与指定的 StringBuffer 比较。 
static String copyValueOf(char[] data) 
          返回指定数组中表示该字符序列的 String。 
static String copyValueOf(char[] data, int offset, int count) 
          返回指定数组中表示该字符序列的 String。 
 boolean endsWith(String suffix) 
          测试此字符串是否以指定的后缀结束。 
 boolean equals(Object anObject) 
          将此字符串与指定的对象比较。 
 boolean equalsIgnoreCase(String anotherString) 
          将此 String 与另一个 String 比较,不考虑大小写。 
static String format(Locale l, String format, Object... args) 
          使用指定的语言环境、格式字符串和参数返回一个格式化字符串。 
static String format(String format, Object... args) 
          使用指定的格式字符串和参数返回一个格式化字符串。 
 byte[] getBytes() 
          使用平台的默认字符集将此 String 编码为 byte 序列,并将结果存储到一个新的 byte 数组中。 
 byte[] getBytes(Charset charset) 
          使用给定的 charset 将此 String 编码到 byte 序列,并将结果存储到新的 byte 数组。 
 void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) 
          已过时。 该方法无法将字符正确转换为字节。从 JDK 1.1 起,完成该转换的首选方法是通过 getBytes() 方法,该方法使用平台的默认字符集。 
 byte[] getBytes(String charsetName) 
          使用指定的字符集将此 String 编码为 byte 序列,并将结果存储到一个新的 byte 数组中。 
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) 
          将字符从此字符串复制到目标字符数组。 
 int hashCode() 
          返回此字符串的哈希码。 
 int indexOf(int ch) 
          返回指定字符在此字符串中第一次出现处的索引。 
 int indexOf(int ch, int fromIndex) 
          返回在此字符串中第一次出现指定字符处的索引,从指定的索引开始搜索。 
 int indexOf(String str) 
          返回指定子字符串在此字符串中第一次出现处的索引。 
 int indexOf(String str, int fromIndex) 
          返回指定子字符串在此字符串中第一次出现处的索引,从指定的索引开始。 
 String intern() 
          返回字符串对象的规范化表示形式。 
 boolean isEmpty() 
          当且仅当 length() 为 0 时返回 true。 
 int lastIndexOf(int ch) 
          返回指定字符在此字符串中最后一次出现处的索引。 
 int lastIndexOf(int ch, int fromIndex) 
          返回指定字符在此字符串中最后一次出现处的索引,从指定的索引处开始进行反向搜索。 
 int lastIndexOf(String str) 
          返回指定子字符串在此字符串中最右边出现处的索引。 
 int lastIndexOf(String str, int fromIndex) 
          返回指定子字符串在此字符串中最后一次出现处的索引,从指定的索引开始反向搜索。 
 int length() 
          返回此字符串的长度。 
 boolean matches(String regex) 
          告知此字符串是否匹配给定的正则表达式。 
 int offsetByCodePoints(int index, int codePointOffset) 
          返回此 String 中从给定的 index 处偏移 codePointOffset 个代码点的索引。 
 boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) 
          测试两个字符串区域是否相等。 
 boolean regionMatches(int toffset, String other, int ooffset, int len) 
          测试两个字符串区域是否相等。 
 String replace(char oldChar, char newChar) 
          返回一个新的字符串,它是通过用 newChar 替换此字符串中出现的所有 oldChar 得到的。 
 String replace(CharSequence target, CharSequence replacement) 
          使用指定的字面值替换序列替换此字符串所有匹配字面值目标序列的子字符串。 
 String replaceAll(String regex, String replacement) 
          使用给定的 replacement 替换此字符串所有匹配给定的正则表达式的子字符串。 
 String replaceFirst(String regex, String replacement) 
          使用给定的 replacement 替换此字符串匹配给定的正则表达式的第一个子字符串。 
 String[] split(String regex) 
          根据给定正则表达式的匹配拆分此字符串。 
 String[] split(String regex, int limit) 
          根据匹配给定的正则表达式来拆分此字符串。 
 boolean startsWith(String prefix) 
          测试此字符串是否以指定的前缀开始。 
 boolean startsWith(String prefix, int toffset) 
          测试此字符串从指定索引开始的子字符串是否以指定前缀开始。 
 CharSequence subSequence(int beginIndex, int endIndex) 
          返回一个新的字符序列,它是此序列的一个子序列。 
 String substring(int beginIndex) 
          返回一个新的字符串,它是此字符串的一个子字符串。 
 String substring(int beginIndex, int endIndex) 
          返回一个新字符串,它是此字符串的一个子字符串。 
 char[] toCharArray() 
          将此字符串转换为一个新的字符数组。 
 String toLowerCase() 
          使用默认语言环境的规则将此 String 中的所有字符都转换为小写。 
 String toLowerCase(Locale locale) 
          使用给定 Locale 的规则将此 String 中的所有字符都转换为小写。 
 String toString() 
          返回此对象本身(它已经是一个字符串!)。 
 String toUpperCase() 
          使用默认语言环境的规则将此 String 中的所有字符都转换为大写。 
 String toUpperCase(Locale locale) 
          使用给定 Locale 的规则将此 String 中的所有字符都转换为大写。 
 String trim() 
          返回字符串的副本,忽略前导空白和尾部空白。 
static String valueOf(boolean b) 
          返回 boolean 参数的字符串表示形式。 
static String valueOf(char c) 
          返回 char 参数的字符串表示形式。 
static String valueOf(char[] data) 
          返回 char 数组参数的字符串表示形式。 
static String valueOf(char[] data, int offset, int count) 
          返回 char 数组参数的特定子数组的字符串表示形式。 
static String valueOf(double d) 
          返回 double 参数的字符串表示形式。 
static String valueOf(float f) 
          返回 float 参数的字符串表示形式。 
static String valueOf(int i) 
          返回 int 参数的字符串表示形式。 
static String valueOf(long l) 
          返回 long 参数的字符串表示形式。 
static String valueOf(Object obj) 
          返回 Object 参数的字符串表示形式。 


   注意:CompareTo方法只有在方法equals(Object)返回true是才返回0;




13.StringBuffer类的常用构造方法
StringBuffer() 
          构造一个其中不带字符的字符串缓冲区,其初始容量为 16 个字符。 
StringBuffer(CharSequence seq) 
          public java.lang.StringBuilder(CharSequence seq) 构造一个字符串缓冲区,它包含与指定的 CharSequence 相同的字符。 
StringBuffer(int capacity) 
          构造一个不带字符,但具有指定初始容量的字符串缓冲区。 
StringBuffer(String str) 
          构造一个字符串缓冲区,并将其内容初始化为指定的字符串内容。 


14.StringBuffer类的常用方法
 StringBuffer append(boolean b) 
          将 boolean 参数的字符串表示形式追加到序列。 
 StringBuffer append(char c) 
          将 char 参数的字符串表示形式追加到此序列。 
 StringBuffer append(char[] str) 
          将 char 数组参数的字符串表示形式追加到此序列。 
 StringBuffer append(char[] str, int offset, int len) 
          将 char 数组参数的子数组的字符串表示形式追加到此序列。 
 StringBuffer append(CharSequence s) 
          将指定的 CharSequence 追加到该序列。 
 StringBuffer append(CharSequence s, int start, int end) 
          将指定 CharSequence 的子序列追加到此序列。 
 StringBuffer append(double d) 
          将 double 参数的字符串表示形式追加到此序列。 
 StringBuffer append(float f) 
          将 float 参数的字符串表示形式追加到此序列。 
 StringBuffer append(int i) 
          将 int 参数的字符串表示形式追加到此序列。 
 StringBuffer append(long lng) 
          将 long 参数的字符串表示形式追加到此序列。 
 StringBuffer append(Object obj) 
          追加 Object 参数的字符串表示形式。 
 StringBuffer append(String str) 
          将指定的字符串追加到此字符序列。 
 StringBuffer append(StringBuffer sb) 
          将指定的 StringBuffer 追加到此序列中。 
 StringBuffer appendCodePoint(int codePoint) 
          将 codePoint 参数的字符串表示形式追加到此序列。 
 int capacity() 
          返回当前容量。 
 char charAt(int index) 
          返回此序列中指定索引处的 char 值。 
 int codePointAt(int index) 
          返回指定索引处的字符(统一代码点)。 
 int codePointBefore(int index) 
          返回指定索引前的字符(统一代码点)。 
 int codePointCount(int beginIndex, int endIndex) 
          返回此序列指定文本范围内的统一代码点。 
 StringBuffer delete(int start, int end) 
          移除此序列的子字符串中的字符。 
 StringBuffer deleteCharAt(int index) 
          移除此序列指定位置的 char。 
 void ensureCapacity(int minimumCapacity) 
          确保容量至少等于指定的最小值。 
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) 
          将字符从此序列复制到目标字符数组 dst。 
 int indexOf(String str) 
          返回第一次出现的指定子字符串在该字符串中的索引。 
 int indexOf(String str, int fromIndex) 
          从指定的索引处开始,返回第一次出现的指定子字符串在该字符串中的索引。 
 StringBuffer insert(int offset, boolean b) 
          将 boolean 参数的字符串表示形式插入此序列中。 
 StringBuffer insert(int offset, char c) 
          将 char 参数的字符串表示形式插入此序列中。 
 StringBuffer insert(int offset, char[] str) 
          将 char 数组参数的字符串表示形式插入此序列中。 
 StringBuffer insert(int index, char[] str, int offset, int len) 
          将数组参数 str 的子数组的字符串表示形式插入此序列中。 
 StringBuffer insert(int dstOffset, CharSequence s) 
          将指定 CharSequence 插入此序列中。 
 StringBuffer insert(int dstOffset, CharSequence s, int start, int end) 
          将指定 CharSequence 的子序列插入此序列中。 
 StringBuffer insert(int offset, double d) 
          将 double 参数的字符串表示形式插入此序列中。 
 StringBuffer insert(int offset, float f) 
          将 float 参数的字符串表示形式插入此序列中。 
 StringBuffer insert(int offset, int i) 
          将 int 参数的字符串表示形式插入此序列中。 
 StringBuffer insert(int offset, long l) 
          将 long 参数的字符串表示形式插入此序列中。 
 StringBuffer insert(int offset, Object obj) 
          将 Object 参数的字符串表示形式插入此字符序列中。 
 StringBuffer insert(int offset, String str) 
          将字符串插入此字符序列中。 
 int lastIndexOf(String str) 
          返回最右边出现的指定子字符串在此字符串中的索引。 
 int lastIndexOf(String str, int fromIndex) 
          返回最后一次出现的指定子字符串在此字符串中的索引。 
 int length() 
          返回长度(字符数)。 
 int offsetByCodePoints(int index, int codePointOffset) 
          返回此序列中的一个索引,该索引是从给定 index 偏移 codePointOffset 个代码点后得到的。 
 StringBuffer replace(int start, int end, String str) 
          使用给定 String 中的字符替换此序列的子字符串中的字符。 
 StringBuffer reverse() 
          将此字符序列用其反转形式取代。 
 void setCharAt(int index, char ch) 
          将给定索引处的字符设置为 ch。 
 void setLength(int newLength) 
          设置字符序列的长度。 
 CharSequence subSequence(int start, int end) 
          返回一个新的字符序列,该字符序列是此序列的子序列。 
 String substring(int start) 
          返回一个新的 String,它包含此字符序列当前所包含的字符子序列。 
 String substring(int start, int end) 
          返回一个新的 String,它包含此序列当前所包含的字符子序列。 
 String toString() 
          返回此序列中数据的字符串表示形式。 
 void trimToSize() 
          尝试减少用于字符序列的存储空间。 


15.类 Properties
构造方法:
Properties() 
          创建一个无默认值的空属性列表。 
Properties(Properties defaults) 
          创建一个带有指定默认值的空属性列表。 
方法:


 String getProperty(String key) 
          用指定的键在此属性列表中搜索属性。 
 String getProperty(String key, String defaultValue) 
          用指定的键在属性列表中搜索属性。 
 void list(PrintStream out) 
          将属性列表输出到指定的输出流。 
 void list(PrintWriter out) 
          将属性列表输出到指定的输出流。 
 void load(InputStream inStream) 
          从输入流中读取属性列表(键和元素对)。 
 void load(Reader reader) 
          按简单的面向行的格式从输入字符流中读取属性列表(键和元素对)。 
 void loadFromXML(InputStream in) 
          将指定输入流中由 XML 文档所表示的所有属性加载到此属性表中。 
 Enumeration<?> propertyNames() 
          返回属性列表中所有键的枚举,如果在主属性列表中未找到同名的键,则包括默认属性列表中不同的键。 
 void save(OutputStream out, String comments) 
          已过时。 如果在保存属性列表时发生 I/O 错误,则此方法不抛出 IOException。保存属性列表的首选方法是通过 store(OutputStream out, String comments) 方法或 storeToXML(OutputStream os, String comment) 方法来进行。 
 Object setProperty(String key, String value) 
          调用 Hashtable 的方法 put。 
 void store(OutputStream out, String comments) 
          以适合使用 load(InputStream) 方法加载到 Properties 表中的格式,将此 Properties 表中的属性列表(键和元素对)写入输出流。 
 void store(Writer writer, String comments) 
          以适合使用 load(Reader) 方法的格式,将此 Properties 表中的属性列表(键和元素对)写入输出字符。 
 void storeToXML(OutputStream os, String comment) 
          发出一个表示此表中包含的所有属性的 XML 文档。 
 void storeToXML(OutputStream os, String comment, String encoding) 
          使用指定的编码发出一个表示此表中包含的所有属性的 XML 文档。 
 Set<String> stringPropertyNames() 
          返回此属性列表中的键集,其中该键及其对应值是字符串,如果在主属性列表中未找到同名的键,则还包括默认属性列表中不同的键。


16.System类
   (1)exit(x)方法
  (2)currentTimeMillis()方法
     产生一个当前的毫秒,这个毫秒就是自1970年1月1日0是起的毫秒数;(long型数值)


17.Date类
使用Date类的无参数构造方法Date()创建的对象可获取当地时间。
    Date();
或System.currentTimeMillis();


18.若要产生[a,b]之间的随机数,其通式为:
   (b-a+1)*Math.random()+a;

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值