Review of Java Fundamentals
613224166 | Object (class) | - root of the class inheritance hierarchy - every Java class inherits the methods of the Object class | |
613224167 | equals(Object obj) (Object) | - indicates whether some other reference is referencing the same object as this reference - public boolean | |
613224168 | shallow equality | equality of two references (whether they are referencing the same object) | |
613224169 | deep equality | equality of the contents of two objects | |
613224170 | checking for deep equality | commonly done by overriding the equals() method | |
613224171 | instanceof | - operator that explicitly checks whether an object is an instance of a class (or one of its subclasses) e.g. math101 instanceof MathCourse | |
613256901 | finalize() (Object) | - returns the memory used for objects marked as garbage to the system - called by the garbage collector on an object when it determines that there are no more references to the object - protected void | |
613256902 | hashcode() (Object) | - returns the hash code for the object as an integer - public int | |
613256903 | hash code of an object | unique identifying value associated with each object | |
613256904 | toString() (Object) | - returns a string that represents the object - by default, returns the name of the object's class, followed by @, then the unsigned hexadecimal representation of the object's hash code - public String | |
613256905 | Array (class) | contains various static methods for manipulating arrays | |
613256906 | copyOf(ptype[] original, int newLength) (Array) | - copies the specified array (of a primitive type), truncating or padding so that the copy has the specified length - numeric types pad with zero, char with null, and boolean with false - public static | |
613256907 | copyOfRange(ptype[] original, int beginIndex, int endIndex) (Array) | - copies the range beginIndex to endIndex-1 of the specified array into a new array - beginIndex must be between [0, original.length] - beginIndex must be <= endIndex - length of returned array = endIndex - beginIndex - public static ptype[] | |
613287228 | toString(ptype[] a) (Array) | - returns a string representation of the array's contents - by default, returns the list of elements, separated by a comma and a space, enclosed in brackets - returns null if the array is null - public static | |
613287229 | binarySearch(ptype[] a, ptype key) (Array) | - searches the array for the key value using the binary search algorithm - returns the index of the key value - array must be sorted before calling (if not, results are undefined) - if the array has duplicate elements with the key value, no way to tell which will be found - for floating point types, all NaN values are considered equivalent and equal - method is not defined for boolean or short - public static int | |
613287230 | sort(ptype[] a) (Array) | - sorts the array into ascending order - for floating point types, uses the total order imposed by the appropriate compareTo() method - for floating point types, all NaN values considered equivalent and equal - method is not defined for boolean or short - public static void | |
613404581 | String (class) | - immutable string type, i.e. the value of the string can't be modified once it is set | |
613404582 | length() (String) | returns the length (int) of a String object | |
613404583 | charAt(int index) (String) | returns the character referenced by the specified index | |
613404584 | compareTo(String otherString) (String) | - indicates whether two strings are equal, or which string comes before the other according to the Unicode table - compares the character sequences of the two strings - returns a negative int if this string precedes the other string, 0 if the strings are equal, a positive int if the other string precedes this string | |
613404585 | + (concatenation operator) | concatenates 2 strings, or a string and a primitive value, to form another string | |
613404586 | substring(int beginIndex, int endIndex) (String) | - returns the portion of a string starting with the character at beginIndex and ending with the character at endIndex-1 - public String | |
613404587 | indexOf(String str, int fromIndex) (String) | - returns the index of the first substring equal to str, starting from fromIndex - public int | |
613404588 | replace(char oldChar, char newChar) (String) | - returns the string obtained by replacing all characters oldChar in the original string with newChar - public String | |
613404589 | trim() (String) | - returns the string obtained by removing all leading and trailing spaces in the original string - public String | |
614634027 | StringBuffer (class) | - implements a mutable string - provides many of the same operations as the String class - provides operations for changing the characters stored in the string | |
614634028 | append(String str) (StringBuffer) | - appends str to the string buffer - public StringBuffer | |
614634029 | insert(int offset, String str) (StringBuffer) | - inserts str into the string buffer at the index offset - any characters originally above offset are moved up - the string buffer length is increased by the length of str - if str is null, the string "null" is inserted - public StringBuffer | |
614634030 | delete(int start, int end) (StringBuffer) | - removes the substring starting at start and ending with end-1 or the end of the string buffer (if no character exists at end-1) - if start == end, no changes are made - throws StringIndexOutOfBoundsException if start < 0, start > string buffer length, or start > end - public StringBuffer | |
614634031 | setCharAt(int index, char ch) (StringBuffer) | - sets the character at index to ch - throws IndexOutOfBoundsException if index < 0 or index >= string buffer length - public void | |
614634032 | replace(int start, int end, String str) | - replaces the characters in the specified substring with the characters in str - if necessary, the string buffer is lengthened to accommodate str - throws StringIndexOutOfBoundsException if start < 0, start > leng |