Java API notes

This page provides stripped-down versions of the Java API documentation for a few classes that we use.

Character operations

(top, full documentation)

Character Method Summary
static int digit(char ch, int radix)
          Returns the numeric value of the character ch in the specified radix.
static char forDigit(int digit, int radix)
          Determines the character representation for a specific digit in the specified radix.
static boolean isDigit(char ch)
          Determines if the specified character is a digit.
static boolean isLetter(char ch)
          Determines if the specified character is a letter.
static boolean isLetterOrDigit(char ch)
          Determines if the specified character is a letter or digit.
static boolean isLowerCase(char ch)
          Determines if the specified character is a lowercase character.
static boolean isUpperCase(char ch)
          Determines if the specified character is an uppercase character.
static boolean isWhitespace(char ch)
          Determines if the specified character is white space according to Java.
static char toLowerCase(char ch)
          Converts the character argument to lowercase.
static char toUpperCase(char ch)
          Converts the character argument to uppercase.

Integer operations

(top, full documentation)

Integer Method Summary
static int parseInt(String s)
          Parses the string argument as a signed decimal integer.
static int parseInt(String s, int radix)
          Parses the string argument as a signed integer in the radix specified by the second argument.
static int signum(int i)
          Returns the signum function (+1,0,-1 for the sign) of the specified int value.
static String toString(int i)
          Returns a String object representing the specified integer.
static String toString(int i, int radix)
          Returns a string representation of the first argument in the radix specified by the second argument.

String operations

(top, full documentation)

String Method Summary
 char charAt(int index)

Returns the char value at the specified index.

 int compareTo(String anotherString)
          Compares two strings lexicographically, returning negative if less, 0 if equal, and positive if greater.
 int compareToIgnoreCase(String str)
          Compares two strings lexicographically, ignoring case differences, returning negative if less, 0 if equal, and positive if greater.
 boolean equals(String anotherString)

Compares this string to anotherString, returning true if they look the same.

 boolean equalsIgnoreCase(String anotherString)
          Compares this String to another String, ignoring case considerations.
 int indexOf(int ch)
          Returns the index within this string of the first occurrence of the specified character. Returns -1 if not found.
 int indexOf(int ch, int fromIndex)
          Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index. Returns -1 if not found.
 int indexOf(String str)
          Returns the index within this string of the first occurrence of the specified substring. Returns -1 if not found.
 int indexOf(String str, int fromIndex)
          Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. Returns -1 if not found.
 boolean isEmpty()
          Returns true if, and only if, length() is 0.
 int lastIndexOf(int ch)
          Returns the index within this string of the last occurrence of the specified character. Returns -1 if not found.
 int lastIndexOf(int ch, int fromIndex)
          Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index. Returns -1 if not found.
 int lastIndexOf(String str)
          Returns the index within this string of the rightmost occurrence of the specified substring. Returns -1 if not found.
 int lastIndexOf(String str, int fromIndex)
          Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index. Returns -1 if not found.
 int length()

Returns the length of this string.

 String substring(int beginIndex)

Returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string.

Examples:

 "unhappy".substring(2) returns "happy"
 "Harbison".substring(3) returns "bison"
 "emptiness".substring(9) returns "" (an empty string)
 
 String substring(int beginIndex, int endIndex)

Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.

Examples:

 "hamburger".substring(4, 8) returns "urge"
 "smiles".substring(1, 5) returns "mile"
 
 String toLowerCase()
          Converts all of the letters in this String to lowercase.
 String toUpperCase()
          Converts all of the letters in this String to uppercase.
 String trim()
          Returns a copy of the string, with leading and trailing whitespace omitted.

Cary Gray
Last modified: Fri Sep 9 14:07:35 CDT 2011