CS122 Flashcards
What does nextInt(max) do?
Returns a random integer from 0 to max-1.
What does nextDouble() do?
Returns a random real number between 0.0 to 1.0.
What does contains(str) do?
Returns true if this string contains str inside.
What does endsWith(str) do?
Returns true if this string ends with str.
What does startsWith(str) do?
Returns true if this string starts with str.
What does equals(str) do?
Returns true if this string is the same as str.
What does equalsIgnoreCase(str) do?
Returns true if this string is the same as str, ignoring capitalization.
What does indexOf(str) do?
Returns the index in this string where given str begins (-1 if not found).
What does length() do?
Returns the number of characters in this string.
What does substring(i,j) do?
Returns characters in this string from index i (inclusive) to index j (exclusive).
What does toLowerCase() do?
Returns a new string with all lowercase characters.
What does toUpperCase() do?
Returns a new string with all uppercase characters.
What does charAt(i) do?
Returns the character at index i.
What does add(index, value) do in List<E>?</E>
Inserts given value at given index, shifting subsequent values right.
What does add(value) do in List<E>?</E>
Inserts given value at the end of the list.
What does contains(value) do in List<E>?</E>
Returns true if the given value is found, false otherwise.
What does indexOf(value) do in List<E>?</E>
Returns the first index where given value is found in the list (-1 if not found).
What does get(index) do in List<E>?</E>
Returns the value at given index.
What does remove(value) do in List<E>?</E>
Removes/returns value at given index, shifting subsequent values left.
What does set(index, value) do in List<E>?</E>
Replaces value at given index with given value.
What does peek() do in Stack<E>?</E>
Returns the top value from the stack without removing it.
What does pop() do in Stack<E>?</E>
Removes the top value from the stack and returns it.
What does push(value) do in Stack<E>?</E>
Places the given value on top of the stack.
What does size() do in Stack<E>?</E>
Returns the number of elements in the stack.