🌐
Codecademy
codecademy.com › docs › c# › strings › .lastindexof()
C# (C Sharp) | Strings | .LastIndexOf() | Codecademy
May 15, 2024 - The .LastIndexOf() method returns the last occurrence of a specified character or substring within a string.
🌐
Quora
quora.com › How-do-you-use-indexOf-and-lastIndexOf-in-Java
How to use indexOf and lastIndexOf in Java - Quora
Answer (1 of 2): indexOf and ... imported by default in all java programs. indexOf returns only the index of first occurrence of the substring present in specified parent string elseif not present returns -1. There...
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › String.html
String (Java SE 17 & JDK 17)
January 20, 2026 - lastIndexOf · (String str) Returns the index within this string of the last occurrence of the specified substring. int · lastIndexOf · (String str, int fromIndex) Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified ...
🌐
Scaler
scaler.com › topics › lastindexof-in-java
lastIndexOf() in Java - Scaler Topics
May 4, 2023 - The lastIndexOf() method in java returns the last occurrence of a specific character or a specific substring in the string; if the occurrence is not found in the original string, it returns -1.
🌐
CodeGym
codegym.cc › java blog › strings in java › java string indexof()
Java String indexOf()
December 26, 2024 - As a Java developer, you must have come across the need to find the position of a character or a substring within a string. Java provides a built-in method called indexOf() in the String class to help us with this task. The indexOf() method in Java is a part of the String class, i.e.
🌐
TechVidvan
techvidvan.com › tutorials › java-string-lastindexof-method
Java String lastIndexOf() Method with Examples - TechVidvan
June 3, 2024 - The Java lastIndexOf() method gives the index (position) of the string's last instance of a given value. To find the first instance of the supplied character(s) in a string, use the indexOf method.
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string lastindexof method
Java String lastIndexOf Method
September 1, 2008 - The java.lang.String.lastIndexOf(String str, int fromIndex) method returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.
Find elsewhere
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.string.lastindexof
String.LastIndexOf Method (Java.Lang) | Microsoft Learn
[<Android.Runtime.Register("lastIndexOf", "(Ljava/lang/String;)I", "")>] member this.LastIndexOf : string -> int ... Returns the index within this string of the last occurrence of the specified substring.
🌐
W3Schools
w3schools.com › java › ref_string_lastindexof.asp
Java String lastIndexOf() Method
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... String myStr = "Hello planet earth, you are a great planet."; System.out.println(myStr.lastIndexOf("planet"));
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-find-the-last-index-of-a-particular-word-in-a-string
Java Program to find the Last Index of a Particular Word in a String - GeeksforGeeks
July 23, 2025 - After initializing with the value now we can use the lastIndexOf() method and should pass the string and word as an argument. After following the above steps then compile the program. Once the program is compiled you will get the output. Example 1: Considering where the character or substring is not present in the string then it will return the last index value. ... // Java Program to find the Last // Index of a particular word // in a string // Importing Classes/Files import java.util.*; public class GFG { // Main driver method public static void main(String[] args) { // String in which char or // substring to be searched String str = "geeksforgeeks"; // Substring to be searched String word = "geeks"; // Printing last index of char // or substring is found // Printing -1 is not found System.out.println(str.lastIndexOf(word)); } }
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › String › lastIndexOf
Java String lastIndexOf() - Find Last Index | Vultr Docs
December 18, 2024 - The lastIndexOf() method in Java is a part of the String class and is used to find the position of the last occurrence of a specified character or substring within a string. This method proves vital in text processing where you need to navigate ...
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
October 20, 2025 - public int lastIndexOf(int ch, int fromIndex) Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index. For values of ch in the range from 0 to 0xFFFF (inclusive), the index returned is the largest value k such ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-string-lastindexof-method
Java String lastIndexOf() Method with Examples - GeeksforGeeks
November 19, 2024 - The String lastIndexOf() method returns the position of the last occurrence of a given character or substring in a String.
🌐
Quora
quora.com › What-is-the-simplest-way-to-get-the-last-two-word-of-a-string-in-Java
What is the simplest way to get the last two word of a string in Java? - Quora
Answer (1 of 3): You can use this: String string = “this is a string ”; String str[] = string.split(‘ ’); System.out.println(“last but one word is “ +str[(str.length-2)】+”last word is” +str[(str.length()-1)】; The former gives the last but one word and the latter the last word.
🌐
CodeGym
codegym.cc › java blog › strings in java › java string lastindexof() method
Java String lastIndexOf() Method
October 11, 2023 - lastIndexOf(int ch, int fromIndex): If this character is represented in the string, this method returns the index of the last occurrence of the ch character, searching backward starting at the specified index.
🌐
Educative
educative.io › answers › what-is-the-lastindexof-method-in-java
What is the lastIndexOf() method in Java?
The lastIndexOf() method in Java returns the index of the last occurrence of a given character or substring​. If the character or the substring is not found, ​ the ​function returns
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › split
String.prototype.split() - JavaScript | MDN
The split() method of String values takes a pattern and divides this string into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-string-lastindexof-method-example
Java String lastIndexOf() Method with example
September 11, 2022 - We are looking for their last occurrence in the String str thats why we are using lastIndexOf() method. If you want to find out the first occurrence of a char or substring in a string then using indexOf() method instead. public class JavaExample { public static void main(String[] args) { String str = "beginnersbook is for beginners"; char ch = 'b'; char ch2 = 's'; String subStr = "beginners"; int posOfB = str.lastIndexOf(ch); int posOfS = str.lastIndexOf(ch2); int posOfSubstr = str.lastIndexOf(subStr); System.out.println(posOfB); System.out.println(posOfS); System.out.println(posOfSubstr); } } Output: Here we are demonstrating the use of lastIndexOf() method in various cases.