Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

endsWith()

Example

Determine whether the string concludes with the specified characters:

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

Definition and Usage

The endsWith() method verifies if a string concludes with the specified character(s).

Tip: Utilize the startsWith() method to examine whether a string begins with the specified character(s).

Syntax

public boolean endsWith(String chars)

Parameter Values

Parameter

Description

chars

A string representing the character(s) to be checked

Technical Details

Returns:

A boolean value:

 

  •          true: if the string ends with the specified character(s)
  •           false: if the string does not end with the specified character(s)