Midterm OOP - Lesson 5 Flashcards
String Methods
A sequence of characters
String
Immutable because it is a constant and cannot be changed once created
String
Syntax on how to declare a String:
String Literal
String x = “Hello World”;
Syntax on how to declare a String:
String Constructor
String x = new String(“Hello World”);
Syntax on how to declare a String:
String Builder - used in .reserve() method
StringBuilder x = new StringBuilder(“Hello World”);
True or False
STRING INDEXING:
Must start with zero (0) the same as array indexing
Truuuu
True or False
STRING INDEXING:
You need to include the whitespace while counting
True
True or False
STRING INDEXING:
Counting the characters in a String must start to zero(0)
False :
counting the characters in a String must start to one(1)
STRING METHODS: Returns integer corresponds to the number of characters in the String including whitespace.
.length()
STRING METHODS: Returns Boolean that used to compare two or more String statement in exact casing.
equals(String)
STRING METHODS: Returns Boolean that used
to compare two or more String statement ignoring case consideration.
.equalsIgnoreCase(String)
String Methods: – convert all the characters in the String to uppercase.
.toUpperCase()
String Methods:convert all the characters in the String to lowercase.
.toLowerCase()
String Methods: Concatenate specified String to the end of another String.
.concat(String)
String Methods:returns a copy of the String by removing any whitespaces.
.trim()