AP Notes, Outlines, Study Guides, Vocabulary, Practice Exams and more!

CSc 3410 - 1.5 Useful Java Classes Flashcards

Review of Java Fundamentals

Terms : Hide Images
613224166Object (class)- root of the class inheritance hierarchy - every Java class inherits the methods of the Object class
613224167equals(Object obj) (Object)- indicates whether some other reference is referencing the same object as this reference - public boolean
613224168shallow equalityequality of two references (whether they are referencing the same object)
613224169deep equalityequality of the contents of two objects
613224170checking for deep equalitycommonly done by overriding the equals() method
613224171instanceof- operator that explicitly checks whether an object is an instance of a class (or one of its subclasses) e.g. math101 instanceof MathCourse
613256901finalize() (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
613256902hashcode() (Object)- returns the hash code for the object as an integer - public int
613256903hash code of an objectunique identifying value associated with each object
613256904toString() (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
613256905Array (class)contains various static methods for manipulating arrays
613256906copyOf(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
613256907copyOfRange(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[]
613287228toString(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
613287229binarySearch(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
613287230sort(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
613404581String (class)- immutable string type, i.e. the value of the string can't be modified once it is set
613404582length() (String)returns the length (int) of a String object
613404583charAt(int index) (String)returns the character referenced by the specified index
613404584compareTo(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
613404586substring(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
613404587indexOf(String str, int fromIndex) (String)- returns the index of the first substring equal to str, starting from fromIndex - public int
613404588replace(char oldChar, char newChar) (String)- returns the string obtained by replacing all characters oldChar in the original string with newChar - public String
613404589trim() (String)- returns the string obtained by removing all leading and trailing spaces in the original string - public String
614634027StringBuffer (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
614634028append(String str) (StringBuffer)- appends str to the string buffer - public StringBuffer
614634029insert(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
614634030delete(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
614634031setCharAt(int index, char ch) (StringBuffer)- sets the character at index to ch - throws IndexOutOfBoundsException if index < 0 or index >= string buffer length - public void
614634032replace(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

Need Help?

We hope your visit has been a productive one. If you're having any problems, or would like to give some feedback, we'd love to hear from you.

For general help, questions, and suggestions, try our dedicated support forums.

If you need to contact the Course-Notes.Org web experience team, please use our contact form.

Need Notes?

While we strive to provide the most comprehensive notes for as many high school textbooks as possible, there are certainly going to be some that we miss. Drop us a note and let us know which textbooks you need. Be sure to include which edition of the textbook you are using! If we see enough demand, we'll do whatever we can to get those notes up on the site for you!