Ask Question

What method of the String object searches the string for an occurence of the specified search string?

the charAt () method

the search () method

the indexOf () method

the substring () method

+4
Answers (1)
  1. 15 March, 09:06
    0
    the indexOf () method

    Explanation:

    The indexOf () method in java returns the first occurrence of the of the string or a character specified in it. It can be used to search both a character or a string.

    for example:-

    import java. util.*;

    import java. lang.*;

    import java. io.*;

    class indexOf

    {

    public static void main (String[] args)

    {

    String s="IamNumber4";

    int l=s. indexOf ("Num"); //using indexOf () method on string object ...

    System. out. println (l);

    }

    }

    Output:-

    3
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What method of the String object searches the string for an occurence of the specified search string? the charAt () method the search () ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers