- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I search a character or substring in java?
You can search for a particular letter in a string using the indexOf() method of the String class. This method which returns a position index of a word within the string if found. Otherwise it returns -1.
Example
public class Test { public static void main(String args[]){ String str = new String("hi welcome to Tutorialspoint"); int index = str.indexOf('w'); System.out.println("Index of the letter w :: "+index); } }
Output
Index of the letter w :: 3
- Related Articles
- Java Program for Anagram Substring Search
- How can I clear or empty a StringBuilder in Java.
- How do I search a list in Java?
- Search index of a character in a string in Java
- How can Tensorflow be used to work with character substring in Python?
- Search for a character from a given position in Java
- Java Program to search for a Substring from a specified index
- How to search for ^ character in a MySQL table?
- How can I search (case-insensitive) in a column using LIKE wildcard?
- How can we convert character array to a Reader in Java?
- How can I search within a table of comma-separated values in MySQL?
- Anagram Substring Search using Python
- How can I reverse a string in Java?
- How I can reverse a Java Array?
- MongoDB $regex operator i or I for case insensitive search

Advertisements