Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Day+4+-++Extended+-Java+Basics+-+Operators+and+Strings

The document provides an overview of Strings in Java, highlighting their immutability and methods for creation, concatenation, and length calculation. It also covers string comparison techniques, including basic comparison, content comparison, case-insensitive comparison, and lexicographical comparison. Additionally, it discusses string manipulation methods such as substring extraction, character replacement, case conversion, and string formatting using 'String.format()'.

Uploaded by

aligangajake10.3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Day+4+-++Extended+-Java+Basics+-+Operators+and+Strings

The document provides an overview of Strings in Java, highlighting their immutability and methods for creation, concatenation, and length calculation. It also covers string comparison techniques, including basic comparison, content comparison, case-insensitive comparison, and lexicographical comparison. Additionally, it discusses string manipulation methods such as substring extraction, character replacement, case conversion, and string formatting using 'String.format()'.

Uploaded by

aligangajake10.3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

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);’

You might also like