Menu
Question Index
...

Write a program to get the index of substring beginning at start index of the given StringBuffer object.If match is not found then returns -1.
For more clarification see the requirements.

Input (StringBuffer, String, int) Output (int)
'HelloWorld', 'World', 2 5
'JavaSchool', 'Java', 0 0
'Mathematics', 't', 5 7
'Computer', 'Com', 3 -1



class GetIndexOfGivenSubStringAccordingToStartIndex
{
    public static void main(String s[])
    {
        System.out.println("Index of given substring is: " + getIndexOfSubString(new StringBuffer("HelloWorld"), "World", 2));

    }


    public static int getIndexOfSubString(StringBuffer stringBuffer, String subString, int startIndex) {
    }

}

Doubts

Problems

Topic: Additional StringBuffer Methods In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App