Computer Science A: Quick Reference Guide
(From: http://apcentral.collegeboard.com/members/article/1,3046,151-165-0-21170,00.html)
class java.lang.Object
// all classes inherit and may override these methods
- boolean equals(Object other)
- String toString()
-------------------------------------------------------------
interface java.lang.Comparable
- int compareTo(Object
other)
// return value < 0 if this is less than other
// return value = 0 if this is equal to other
// return value > 0 if this is greater than other
-------------------------------------------------------------
class java.lang.Integer
implements java.lang.Comparable
- Integer(int
value)
// constructor
- int intValue()
-------------------------------------------------------------
class java.lang.Double
implements java.lang.Comparable
- Double(double value)
// constructor
- double doubleValue()
-------------------------------------------------------------
class java.lang.String
implements java.lang.Comparable
- int length()
- String substring(int
from, int to)
// returns the substring beginning at from
// and ending at to-1
- String substring(int
from)
// returns substring(from,
length())
- int indexOf(String
s)
// returns the index of the first occurrence of s;
// returns -1 if not found
-------------------------------------------------------------
class java.lang.Math
- static int abs(int x)
- static double abs(double
x)
- static double pow(double base, double exponent)
- static double sqrt(double x)
-------------------------------------------------------------
class java.util.Random
- int nextInt(int n)
// returns an integer in the range from 0 to n-1 inclusive
- double nextDouble()
// returns a double in the range [0.0, 1.0)
-------------------------------------------------------------
class java.util.ArrayList
- int size()
- boolean add(Object x)
// appends x to the end of list; returns true
- Object get(int
index)
// returns the element at the specified position
- Object set(int
index, Object x)
// replaces the element at index
with x
// returns the element formerly at the specified position
- void add(int
index, Object x)
// inserts x at position index, sliding elements
// at position index and higher to the right
// (adds 1 to their indices) and adjusts size
- Object remove(int
index)
// removes element from position index, sliding elements
// at position index
+ 1 and higher to
the left
// (subtracts 1 from their indices) and adjusts size
// returns the element formerly at the specified position