
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Variable Types
- Java - Basic Datatypes
- Java - Basic Operators
- Java Control Statements
- Java - Loop Control
- Java - Decision Making
- Java - If-else
- Java - Switch
- Java - For Loops
- Java - For-Each Loops
- Java - While Loops
- Java - do-while Loops
- Java - Break
- Java - Continue
- Object Oriented Programming
- Java - Object & Classes
- Java - Methods
- Java - Constructors
- Java - Access Modifiers
- Java - Inheritance
- Java - Polymorphism
- Java - Overriding
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java - Inner classes
- Java Data Types
- Java - Characters
- Java File Handling
- Java - Files and I/O
- Java Error & Exceptions
- Java - Exceptions
- Java Multithreading
- Java - Multithreading
- Java Synchronization
- Java - Synchronization
- Java - Inter-thread Communication
- Java - Thread Deadlock
- Java - Thread Control
- Java Networking
- Java - Networking
- Java - URL Processing
- Java - Generics
- Java Collections
- Java - Collections
- Java List Interface
- Java - List Interface
- Java Queue Interface
- Java - Queue Interface
- Java Map Interface
- Java - Map Interface
- Java - SortedMap Interface
- Java Set Interface
- Java - Set Interface
- Java - SortedSet Interface
- Java Data Structures
- Java - Data Structures
- Java - Enumeration
- Java Collections Algorithms
- Java - Collections
- Java - Iterators
- Java - Comparators
- Java Miscellenous
- Java - Regular Expressions
- Java - Serialization
- Java - Sending Email
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Java - String endsWith() Method
Description
This method tests if this string ends with the specified suffix.
Syntax
Here is the syntax of this method −
public boolean endsWith(String suffix)
Parameters
Here is the detail of parameters −
suffix − the suffix.
Return Value
This method returns true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise. Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the equals(Object) method.
Example
public class Test { public static void main(String args[]) { String Str = new String("This is really not immutable!!"); boolean retVal; retVal = Str.endsWith( "immutable!!" ); System.out.println("Returned Value = " + retVal ); retVal = Str.endsWith( "immu" ); System.out.println("Returned Value = " + retVal ); } }
This will produce the following result −
Output
Returned Value = true Returned Value = false
java_strings.htm
Advertisements