Java类库由以下几个包组成:
java.lang java.io java.util java.awt java.applet java.net
java基础类库在java.lang包中: Object class method: 1.protected Object clone() 2.public boolean equals(Object obj) 3.public final class getClass() 4.protected void finalize() 5.public String toString() 6.public final void notify()
Math class method: 1.public static double abs(double d) 2.public static double exp(double d)求e的d次幂 3.public static double floor(double d)求不大于d的最大整数 4.public static double log(doulble d)求d 的自然对数 5.public static double max(double d1,double d2) 6.public static double min(double d1,double d2) 7.public static double pow(double d1,double d2)d1的d2次方 8.public static double random()获取0~1中的随机数 9.public static double rint(double d)求d的4舍5入 10.pulblic static double sqrt(double d) 11.public static double sin(double d) 12.public static double cos(double d) 13.public static double tan(double d) 此全为静态变量..可用Math.method()表示
System class 属性: public static InputStream in; pulbic static PrintStream out; public static PrintStream err; method: public static long currentTimeMillis() public static void exit(int status) public static void gc()强制调用虚拟机的垃圾回收功能
String class 分为String 类和StringBuffer类 String: 构造函数: public String(); public Stirng(StringValue); public String(StringBuffer buffer); public String(char value[]); method: public int length(); public boolean startsWith(String prefix) public boolean endsWith(Stirng suffix) 查找字符串中指定的字符 public int indexOf(char ch) public int indexOf(char ch,int fromIndex) public int lastIndexOf(char ch) public int lastInderOf(char ch,int fromIndex) 查找字符串中指定的子串 public int indexOf(String str) public int indexOf(String str,int fromIndex) public int lastIndexOf(String str) public int lastInderOf(String str,int fromIndex) 比较两字符串: public int compareTo(String str) public boolean equals(Object obj) public boolean equalsIgnoreCase(String str) 连接两字符串 public String concat(String str) 求字符串中的字符和子串 public char chaAt(int index) public String substirng(int startIndex,int endIndex) public String substring(int startIndex)
StringBuffer: 构造函数: public StringBuffer() public StringBuffer(int length) public StringBuffer(String str) method: public int length() public int capacity() public void setLength(int newLength) public charAt(int index) public void setChartAt(int index,char ch) public StringBuffer append(<参数类型> <参数名>) public StringBuffer insert(int <输入位置>,<参数类型> <参数名>)
|
|