1/50
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Characters
Java uses primitive data type char when working with _____.
Wrapper Class Character
Java provides ________ for primitive data type char. Character class offers several useful class like static methods for manipulating characters.
Autoboxing or Unboxing
The Java compiler creates a Character object. If you pass a primitive char into a method that expects an object, the compiler automatically converts the char to a Character.
Strings
String greeting = “Hello TIP!”
In the Java programming language, ______ are objects. In the following example, the String object "greeting" has the value "Hello TIP".
Immutable
String class is _______; once it is created, a String object cannot be changed.
Char Array
Strings in Java are objects that are backed internally by a ______. Since arrays are immutable, this means that whenever a change to a String is made, an entirely new String is created.
charAt()
Returns the character at the specified index(position).
codePointAt()
Returns the Unicode of the character at the specified index.
codePointBefore()
Returns the Unicode of the character before the specified index.
codePointCount()
Returns the Unicode in the specified text range of the String.
compareTo()
Compares two strings lexicographically.
compareToIngnoreCase()
Compares two strings lexicographically, ignoring case differences.
concat()
Appends a string to the end of another string.
contains()
Checks whether a string contains a sequence of characters.
contentEquals()
Checks whether a string contains the same sequence of characters of the specified CharSequence or StringBuffer.
copyValue()
Returns a String that represents the characters of the character array.
equals()
Compares two Strings. Returns true if the strings are equal, and false if not
equalsIgnoreCase()
Compares two strings, ignoring case considerations
format()
Returns a formatted string using the specified locale, format string, and arguments
getBytes()
Encodes this String into a sequence of byte using the named charset, storing the result into a new byte array.
getChars()
Copies characters from string to an array of chars.
hashCode()
Returns the hash code of a string
indexOf()
Returns the position of the first found occurrence of a specified string
intern()
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
isEmpty()
Checks whether a string is empty or not.
lastIndexOf()
Returns the position of the last found occurrence of specified characters in a string
length()
Returns the length of the specified string
matches()
Searches a string for a match against a regular expression, and returns the matches
offsetByCodePoints()
Returns the index within this String that is offset from the given index by codePointOffset code points
regionMatches()
Tests if two string regions are equal
replace()
Searches a string for a specified value, and returns a new string where the specified values are replaced
replaceFirst()
Replaces the first occurrence of a substring that matches the given regular expression with the given replacement
replaceAll()
Replaces each substring of this string that matches the given regular expression with the given replacement
split()
Splits a string into an array of substrings
startsWith()
Checks whether a string starts with specified characters
subSequence()
Returns a new character sequence that is a subsequence of this sequence
substring()
Extracts the characters from a string, beginning at a specified start position, and through the specified number of character
toCharArray()
Converts this string to a new character array
toLowerCase()
Converts a string to lower case letters
toString()
Returns the value of a String object
toUpperCase()
Converts a string to upper case letters
trim()
Removes whitespace from both ends of a string
valueOf()
Returns the primitive value of a String object
String Literal (Static Memory)
Using new keyword (Heap Memory)
Two ways to create string in Java.
CharSequence Interface
Used for representing the sequence of Characters in Java.
String
StringBuffer
StringBuilder
StringTokenizer
Classes that implement CharSequence.
StringBuffer
A peer class of String, it is mutable in nature and it is thread safe class, we can use it when we have multi threaded environment and shared object of string buffer. As it is thread safe so there is extra overhead, so it is mainly used for multithreaded program.
StringBuilder
Represents an alternative to String and StringBuffer Class, as it creates a mutable sequence of characters and it is not thread safe. It is used only within the thread, so there is no extra overhead, so it is mainly used for single threaded program.
StringTokenizer
Used to break a string into tokens.
String Literal
Using new Keyword
How Strings are Stored in Java Memory
Heap
All objects in Java are stored in a ______. The reference variable is to the object stored in the stack area or they can be contained in other objects which puts them in the heap area also.