
- 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 startsWith() Method
Description
This method has two variants and tests if a string starts with the specified prefix beginning a specified index or by default at the beginning.
Syntax
Here is the syntax of this method −
public boolean startsWith(String prefix)
Parameters
Here is the detail of parameters −
prefix − the prefix to be matched.
Return Value
It returns true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.
Example
import java.io.*; public class Test { public static void main(String args[]) { String Str = new String("Welcome to Tutorialspoint.com"); System.out.print("Return Value :" ); System.out.println(Str.startsWith("Welcome") ); System.out.print("Return Value :" ); System.out.println(Str.startsWith("Tutorials") ); } }
This will produce the following result −
Output
Return Value :true Return Value :false
java_strings.htm
Advertisements