Math
1 2 3 4 5 6 7 8 9 10
| public final class Math extends Object { public static final double E = 2.7182818284590452354; public static final double PI = 3.14159265358979323846; public static double abs(double a) public static double random() public static double pow(double a, double b) public static double sqrt(double a) public static double sin(double a) }
|
String
1 2 3 4 5 6 7 8 9 10 11 12
| public final class String extends Object implements java.io.Serializable, Comparable<String>,CharSequence { private final char value[]; public String() public String(String original) public String toString() public int length() public boolean equals(Object obj) public boolean equalsIgnoreCase (String s) public int compareTo(String s) public int compareToIgnoreCase(String str) }
|
Integer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public final class Integer extends Number implements Comparable<Integer> { public static final int MIN_VALUE=0x80000000; public static final int MAX_VALUE = 0x7fffffff; private final int value; public Integer(int value) public Integer(String s) throws NumberFormatException public static int parseInt(String s) throws NumberFormatException public String toString() public static String toBinaryString(int i) public static String toOctalString(int i) public static String toHexString(int i) public boolean equals(Object obj) public int compareTo(Integer iobj) }
|
Comparable
1 2 3 4
| public interface Comparable<T> { int compareTo(T cobj) }
|
其中,是Comparable接口的参数,表示一个类。
举个栗子:MyDate类对象比较大小
1 2 3 4 5 6 7 8 9 10 11
| public class MyDate implements Comparable<MyDate> { public int compareTo(MyDate d) { if (this.year==d.year && this.month==d.month&& this.day==d.day) return 0; return (this.year>d.year || this.year==d.year && this.month>d.month || this.year==d.year && this.month==d.month && this.day>d.day) ? 1 : -1; } }
|