Java Basics:
Operators
and Strings
EXTENTED
Strings in Java
What are Strings?: Strings represent a sequence of
characters. Strings in Java are immutable.
Strings in Java
What are Strings?: Strings represent a sequence of
characters. Strings in Java are immutable.
Creating Strings: Strings can be created using string
literals or the ‘new’ keyword.
Strings in Java
What are Strings?: Strings represent a sequence of
characters. Strings in Java are immutable.
Creating Strings: Strings can be created using string
literals or the ‘new’ keyword.
Concatenation: Joining two or more strings together
using the ‘+’ operator.
Strings in Java
What are Strings?: Strings represent a sequence of
characters. Strings in Java are immutable.
Creating Strings: Strings can be created using string
literals or the ‘new’ keyword.
Concatenation: Joining two or more strings together
using the ‘+’ operator.
Length of a String: Find the number of characters in a
string. Method: ‘length()’.
Strings in Java
What are Strings?: Strings represent a sequence of
characters. Strings in Java are immutable.
Creating Strings: Strings can be created using string
literals or the ‘new’ keyword.
Concatenation: Joining two or more strings together
using the ‘+’ operator.
Length of a String: Find the number of characters in a
string. Method: ‘length()’.
Character at a Specific Index: Get the character at a
specific index in a string. Method: ‘charAt()’.
Comparing Strings
Basic String Comparison Using ‘==’: Compares two
variables to see if they refer to the same object in 3
memory. Method: ‘==’.
Comparing Strings
Basic String Comparison Using ‘==’: Compares two
variables to see if they refer to the same object in 3
memory. Method: ‘==’.
Comparing Strings Using ‘equals()’: Compares the
content of two strings. Method: ‘equals()’.
Comparing Strings
Basic String Comparison Using ‘==’: Compares two
variables to see if they refer to the same object in 3
memory. Method: ‘==’.
Comparing Strings Using ‘equals()’: Compares the
content of two strings. Method: ‘equals()’.
Ignoring Case with ‘equalsIgnoreCase()’: Compares
strings without considering their case. Method:
‘equalsIgnoreCase()’.
Comparing Strings
Basic String Comparison Using ‘==’: Compares two
variables to see if they refer to the same object in 3
memory. Method: ‘==’.
Comparing Strings Using ‘equals()’: Compares the
content of two strings. Method: ‘equals()’.
Ignoring Case with ‘equalsIgnoreCase()’: Compares
strings without considering their case. Method:
‘equalsIgnoreCase()’.
Comparing Strings Lexicographically with
‘compareTo()’: Compares two strings lexicographically
(dictionary order). Method: ‘compareTo()’.
More on Strings
Substring: Extract part of a string with
substring().
More on Strings
Substring: Extract part of a string with
substring().
Replace Characters: Modify characters
in a string with replace().
More on Strings
Substring: Extract part of a string with
substring().
Replace Characters: Modify characters
in a string with replace().
Changing Case: Convert string to
upper case with toUpperCase() or
lower case with toLowerCase().
Formatting Strings
What is String Formatting?: String formatting
creates strings with embedded variables or
expressions and formats them in a specific way.
Formatting Strings
What is String Formatting?: String formatting
creates strings with embedded variables or
expressions and formats them in a specific way.
Using ‘String.format()’: The ‘String.format()’
method formats strings with placeholders.
Example: ‘String.format("Hello, %s!", name);’
Formatting Strings
What is String Formatting?: String formatting
creates strings with embedded variables or
expressions and formats them in a specific way.
Using ‘String.format()’: The ‘String.format()’
method formats strings with placeholders.
Example: ‘String.format("Hello, %s!", name);’
Formatting Numbers: Format numbers to
control decimal places or add commas.
Example: ‘String.format("%.2f", 1234.567);’