bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String length() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java String length() Method?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The length() method returns the length of a specified string.
Definition and Usage
Java String length() Method

❮ String Methods

Example

String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
System.out.println(txt.length());

Definition and Usage

The length() method returns the length of a specified string.

Note

The length of an empty string is 0.

Syntax

public int length()

Parameters

None.

Technical Details

Returns:An int value, representing the length of the string

Previous

Java String lastIndexOf() Method

Next

Java String matches() Method