Pre-Finals Flashcards
(34 cards)
Data type that contains a fixed set of constants. Best used when all
possibilities of the values of the class are known.
Enumeration (enum)
Common examples of enums
Compass directions
o Months of the year
o Cards in a deck
Enumeration list value
Enum constants
Returns the name of the calling constant object
toString()
Returns an integer that represents the constant’s position in the list of constants; the first position is 0
ordinal()
Returns a negative integer if the calling object’s ordinal value is less than that of the argument, 0 if they are the same, and a positive integer if the calling object’s ordinal value is greater than that of the argument
compareTo()
Returns true if its argument is equal to the calling object’s value
equals()
Accepts a string parameter and returns an enumeration constant
valueOf()
Returns an array of the enumerated constants
values()
used to describe a data type that allows only appropriate behaviors.
Type-safe
create a class within another class and store them
Nested Class
access to all static methods of the top-level class
Static member class
requires an instance; it has access to all data and methods of the top-level class.
Non-static member class
defined within a method body
Local class
special case of a local class that has no identifier
Anonymous class
Sequence of characters that represent a string or multiple strings.
Regular expression (regex)
This method determines what the string should match against and specifies multiple values.
matches()
this package has classes to help form and use regular expressions.
java.util.regex.package
allows for the method matches to check if equal and returns true accordingly.
symbol |
used in regular expressions for character variability.
Square brackets “[]”
wildcard operator that represents any single character in regular expression
Dot “.”
Symbol in regular expressions that indicates the number of times a specified character appears in a matching string.
Repetition Operator
0 or more occurrences
*
0 or 1 occurrence
?