String characters can be found in tail of String at last occurrence with the help of lastIndexOf() method in java. lastIndexOf() method returns a value in integer. If string is found successfully it will return integer in positive value, otherwise return a negative value. Use of String lastIndexOf() in java is shown below.
Example of String lastIndexOf() in java, JSP
public class StringLastIndexOfExample { public static void main(String[] args) { String string = "String is good String"; int cntIndex=string.lastIndexOf("String"); System.out.println("String found at :"+cntIndex); } }
Output
String found at :15
Tags: String




Link to Us