___ are a sequence of characters widely use in java programming.
Strings
___ is a series of characters found in a double quotes and is considered constants
String Literal
it commonly uses characters, symbols, and letters but it should be enclosed with double quotes.
String
This is an example with a what?
String strName;
strName = “Harley”;
string literal and strName
In this part Each character in a string has a specific position wherein the position of the first character starts at index 0. What is this ?
String Index
A ___ is a block of code that initializes a newly created object. The String class has 13 constructors that provide the initial value of the string using different sources.
constructor
The String class has ___ constructors that provide the initial value of the string using different sources.
13
Recite the two(2) ways on how a string can be written.
•by directly assigning a string literal to a String object.
•by using the new keyword and String constructor to create a String object.
What is the default constructor to create an empty string.
String()
the most common String constructor used in Java. It creates a new String
object in the heap area and stores the given value in it.
String(String str)
it used to create a String object and store the array of characters in it.
String(char chars[])
It used to create and initialize a String
object with a subrange of a character array.
String(char chars [], int startIndex, int count)
This used to create a new String object by decoding the given array of bytes such as by decoding ASCII values according to the system’s default character set.
String(byte byte Arr[])
this constructor also creates a new String object by decoding the ASCII values of the current string using the system’s default character.
String(byte byteArr[], int startIndex, int count)
The String class has various methods used to perform operations on Strings.
String Methods
This method returns the character present in the specified index.
CharAt()
This method removes the leading (starting) and trailing(ending) whitespaces from a string.
Trim()
This method changes the matching occurrences of a text or character in the string with the new text or character.
replace()
This method returns true if two strings are identical and false if otherwise.
equals()
This method changes all characters in the string to lowercase or minuscule characters.
toLowerCase()
This method returns the number of characters in a string.
length()
This method returns a new string based on two (2) concatenated or joined strings.
concat()
This method returns the index or position of the first occurrence of the specified character/substring within
the string.
indexOf()
This method compares or matches two (2) strings based on the dictionary order. This comparison is based on
the Unicode value of each character in the string.
Compareto()