Java String Last Index Of lastIndexOf(char ch, String str)

Here you can find the source of lastIndexOf(char ch, String str)

Description

last Index Of

License

Open Source License

Declaration

public static int lastIndexOf(char ch, String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int lastIndexOf(char ch, String str) {
        if (str.charAt(str.length() - 1) == ch) {
            return str.length() - 1;
        }//from  w w w.  j av a 2s  . c o  m
        if (str.length() <= 1) {
            return -1;
        }
        return lastIndexOf(ch, str.substring(0, str.length() - 1));
    }
}

Related

  1. lastIndexof(char chr, int pos, CharSequence str)
  2. lastIndexOf(CharSequence chars, String searched)
  3. lastIndexOf(CharSequence charSeq, char ch)
  4. lastIndexOf(CharSequence cs, int searchChar, int start)