bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String startsWith() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java String startsWith() 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.

___ myStr = "Hello";
3Order

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

The startsWith() method checks whether a string starts with the specified character(s).
Definition and Usage
Java String startsWith() Method

❮ String Methods

Example

String myStr = "Hello";
System.out.println(myStr.startsWith("Hel"));   // true
System.out.println(myStr.startsWith("llo"));   // false
System.out.println(myStr.startsWith("o"));     // false

Definition and Usage

The startsWith() method checks whether a string starts with the specified character(s).

Tip

Use the endsWith() method to check whether a string ends with the specified character(s).

Syntax

public boolean startsWith(String
chars )

Parameter Values

ParameterDescription
charsA String , representing the character(s) to check for

Technical Details

Returns:A boolean value: true - if the string starts with the specified character(s) false - if the string does not start with the specified character(s)
  • true - if the string starts with the specified character(s)
  • false - if the string does not start with the specified character(s)

Previous

Java String split() Method

Next

Java String subSequence() Method