Java Strings

Strings are used to store text.

Tutorials dojo strip

A String variable is a series of characters enclosed in double quotes:

Example

Create a String variable and assign it a value:

JAVA




String Length

In Java, a String is actually an object that comes with methods to perform various operations. For instance, you can find out the length of a string using the length() method:

Example

JAVA




More String Methods

Java provides many methods for strings, such as toUpperCase() and toLowerCase():

Example

JAVA




Finding a Character in a String

The indexOf() method returns the position of the first occurrence of a specified text within a string (including spaces):

Example

JAVA
Tutorials dojo strip