Menu
Question Index
...

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

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



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

    }


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

}

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