Find Index Of A Particular Character Example Java Program
Definition
This method indexOf() is an inbuilt method of strings which is used to find the index of a particular character or string.Syntax
public int indexOf(int ch )
Find Index Of A Particular Character Example Program
public class FindIndexOfCharacter { public static void main(String args[]) { String Str = new String("abcdefghijklmnopqrstuvwxyz"); System.out.print("Index of o is :" ); System.out.println(Str.indexOf( 'o' )); System.out.print("Index of f is :" ); System.out.println(Str.indexOf( 'f')); System.out.print("Index of w is :" ); System.out.println( Str.indexOf('w')); System.out.print("Index of g is :" ); System.out.println( Str.indexOf('g')); } }
Sample Output
Output is: Index of o is :14 Index of f is :5 Index of w is :22 Index of g is :6
String Programs
- Check Case Of A Character Example Java Program
- String Reverse Example Java Program
- Trim A String Example Java Program
- Find all Substrings of a given string Example Java Program
- Repetitions In String Example Java Program
- First Repeated Character Example Java Program
- String Buffer Example Java Program
- String Builder Example Java Program
- String Comparison Example Java Program
- Convert A String To Array Example Java Program
- Equals and equalsIgnoreCase Example Java Program
- Convert String To ArrayList Example Java Program
- Convert String To Lowercase Example Java Program
- String To CharacterArray Example Java Program
- Convert To Uppercase Example Java Program
- Find The Character At A Particular Index Example Java Program
- Find Index Of A Particular Character Example Java Program
- Find Index Of A Particular String Example Java Program
- Replace Character In A String Example Java Program
- String Concatenation Example Java Program
- String Length Example Java Program
- Capitalize the starting letter of each word in a sentence
- Convert Character Array to String Example Java Program
- Check Input Strings are Anagram or Not
Read More Articles
- Multiple Inheritance Using Interface Example Java Program
- Single Inheritance Example Java Program
- Multilevel Inheritance Example Java Program
- Hierarchical Inheritance Example Java Program
- Find all Substrings of a given string Example Java Program
- Create Matrix Example Java Program
- Sum Of Three Numbers Example Java Program
- Twin Prime Example Java Program
- Heap Sort Example Java Program
- Compile Time Polymorphism Example Java Program