1/39
Flashcards covering Java text processing, String methods, the StringBuilder class, and numeric wrapper classes based on Chapter 9 of Java Control Structures Through Objects.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Wrapper classes
Classes that are "wrapped around" a primitive data type, allowing you to create objects to represent a primitive.
Immutable
A characteristic of wrapper class objects meaning that once you create an object, you cannot change the object’s value.
java.lang
The package that contains wrapper classes, meaning no import statement is required to use them.
Character class
A class that allows a char data type to be wrapped in an object and provides static methods for testing, processing, and conversion.
Character.isDigit(charch)
Returns true if the argument passed into ch is a digit from 0 through 9. Otherwise returns false.
Character.isLetter(charch)
Returns true if the argument passed into ch is an alphabetic letter. Otherwise returns false.
Character.isLetterOrDigit(charch)
Returns true if the argument passed into ch contains a digit from 0 through 9 or an alphabetic letter. Otherwise returns false.
Character.isLowerCase(charch)
Returns true if the argument passed into ch is a lowercase letter. Otherwise returns false.
Character.isUpperCase(charch)
Returns true if the argument passed into ch is an uppercase letter. Otherwise returns false.
Character.isSpaceChar(charch)
Returns true if the argument passed into ch is a space character. Otherwise returns false.
Character.isWhiteSpace(charch)
Returns true if the argument passed into ch contains a whitespace character (a space, tab, or newline character). Otherwise returns false.
Empty string
A string that has a length of 0, which means it contains no characters.
Blank string
A string that is either empty or contains only whitespace characters.
isBlank()
A String class method that returns true if the calling string is empty (its length is 0) or it contains only whitespace characters.
isEmpty()
A String class method that returns true if the length of the calling string is 0.
Substring
A string that is part of another string.
contains
A String class method that returns true if the calling string object contains a particular substring.
startsWith(Stringstr)
Determines whether a string begins with a specified substring using a case sensitive comparison.
endsWith(Stringstr)
Determines whether a string ends with a specified substring using a case sensitive comparison.
regionMatches
A String class method that determines if specified regions of two strings match, with an optional boolean to ignore case.
indexOf
Returns the first location of a substring or character in the calling String Object; returns negative 1 if not found.
lastIndexOf
Returns the last location of a substring or character in the calling String Object; returns negative 1 if not found.
substring(intstart)
A String class method used to extract and return a substring beginning at a start location.
getChars
A String class method that stores a substring in a char array.
toCharArray
A String class method that returns the String object’s contents in an array of char values.
concat
Returns a String object that is the concatenation of two String objects.
replace(charoldChar,charnewChar)
Returns a String object with all occurrences of one character being replaced by another character.
indent(intn)
Returns a copy of the calling String object with each line's indentation adjusted; positive n adds spaces, while negative n removes them.
strip()
Returns a copy of a String object with all leading and trailing whitespace characters removed.
valueOf
Static overloaded methods in the String class that return a String object representation of a primitive value or a character array.
StringBuilder class
A class similar to String, but whose objects are mutable and can grow or shrink in size to accommodate changes.
append
A StringBuilder method that appends a string representation of an argument, such as a primitive or char array, to the current contents.
insert(intstart,item)
A StringBuilder method that accepts a position and a value to be inserted at that specific location.
deleteCharAt(intindex)
A StringBuilder method used to delete a single character at a specified position.
split(Stringdelimiter)
A String class method that tokenizes a String object and returns an array of String objects where each element is one token.
Numeric Primitive Wrapper Classes
Includes Byte, Double, Float, Integer, Long, and Short, which apply to their respective numeric primitive types.
Parse methods
Static methods in numeric wrapper classes, such as parseInt, that convert a string representing a number into a numeric data type.
NumberFormatException
The exception thrown by parse methods if the String object does not represent a numeric value.
Autoboxing
The automatic conversion the Java compiler makes between the primitive types and their corresponding object wrapper classes when a primitive value is assigned to a wrapper class variable.
Unboxing
The process of automatically converting a wrapper class object to its corresponding primitive data type.