Java StringBuffer indexOf(String str, int fromIndex) Method Explained | Java Tutorial

Publié le: 07 avril 2016
sur la chaîne: Ram N Java
247
3

In this Java tutorial, we delve into the `indexOf(String str, int fromIndex)` method of the StringBuffer class. This method allows you to find the index of the first occurrence of a specified string within the StringBuffer, starting the search from a particular index position.

*Description:*
The `indexOf(String str, int fromIndex)` method in Java StringBuffer searches for the specified string within the StringBuffer object, starting the search from the given index (`fromIndex`). If the string is found, it returns the index of the first occurrence of the specified string within the StringBuffer. If the string is not found, it returns -1.

*Syntax:*
```java
public int indexOf(String str, int fromIndex)
```

*Parameters:*
`str`: The substring to search for.
`fromIndex`: The index from which to start the search.

*Returns:*
The index of the first occurrence of the specified substring within the StringBuffer, starting from the specified index (`fromIndex`), or -1 if the substring is not found.

*Example:*
```java
StringBuffer sb = new StringBuffer("Hello World");
int index = sb.indexOf("World", 3); // Searches for "World" starting from index 3
System.out.println("Index of 'World': " + index); // Output: Index of 'World': 6
```

*Subscribe for more Java tutorials!* Don't forget to like, share, and subscribe for more Java programming tutorials and updates on our channel!

Java StringBuffer [indexOf(String str, int fromIndex) method] | Java Tutorial

Java Source Code here:
http://ramj2ee.blogspot.com/2016/04/j...

Click the below link to download the code:
https://drive.google.com/file/d/1g27F...

Github Link:
https://github.com/ramram43210/Java/t...

Bitbucket Link:
https://bitbucket.org/ramram43210/jav...

#Java,#StringBuffer,#JavaTutorial,#JavaBasics,#JavaStringBuffer,#StringBufferinJava


Sur cette page du site, vous pouvez voir la vidéo en ligne Java StringBuffer indexOf(String str, int fromIndex) Method Explained | Java Tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Ram N Java 07 avril 2016, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 247 fois et il a aimé 3 téléspectateurs. Bon visionnage!