CSE142 Midterm Cheat Sheet Math Method Description -------------------------------------- Math.abs(n) absolute value of n Math.max(x, y) maximum of x and y Math.min(x, y) minimum of x and y String Method Description ----------------------------------------------------------------------------- charAt(index) character at a specific index indexOf(text) index of a particular string (-1 if not found) length() number of characters in string substring(start, stop) characters from start (inclusive) to stop (exclusive) substring(start) characters from start to end of string toLowerCase() lowercase version of string toUpperCase() uppercase version of string Syntax Examples: for (int i = 1; i <= n; i++) { System.out.println("****"); } if (n < 0) { System.out.println("negative"); } if (n < 0) { System.out.println("negative"); } else { System.out.println("not negative"); } while (n < 200) { n = n * 2; }
Stuart Reges
Last modified: Wed Feb 9 13:02:04 PST 2011