Used by the indexOf(CharSequence methods) as a green implementation of indexOf. - Java java.lang

Java examples for java.lang:String Index

Introduction

The following code shows how to Used by the indexOf(CharSequence methods) as a green implementation of indexOf. .

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String cs = "java2s.com";
        String searchChar = "2";
        int start = 42;
        System.out.println(indexOf(cs, searchChar, start));
    }/* ww w  . j a v  a2s  .  c  o m*/

    /**
     * Used by the indexOf(CharSequence methods) as a green implementation of
     * indexOf.
     * 
     * @param cs
     *            the {@code CharSequence} to be processed
     * @param searchChar
     *            the {@code CharSequence} to be searched for
     * @param start
     *            the start index
     * @return the index where the search sequence was found
     */
    public static int indexOf(CharSequence cs, CharSequence searchChar,
            int start) {
        return cs.toString().indexOf(searchChar.toString(), start);
    }
}

Related Tutorials