Java - Write code to search index Of a char inside a string

Requirements

Write code to search index Of a char inside a string

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        char searchChar = 'a';
        int startPos = 2;
        System.out.println(indexOf(str, searchChar, startPos));
    }/*  w  w  w  .  j a v  a  2  s . c om*/

    public static int indexOf(String str, char searchChar, int startPos) {
        if (isEmpty(str))
            return -1;
        else
            return str.indexOf(searchChar, startPos);
    }

    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }
}