amorrison6849 amorrison6849
  • 07-08-2019
  • Computers and Technology
contestada

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

Respuesta :

ExieFansler ExieFansler
  • 13-08-2019

Answer:

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

Answer Link

Otras preguntas

Pls help 10 points !!!
Need Help ASAP Right now January 6 2022 1:25 PM
21.) A car on a road trip went 240 miles in 3.2 hours. For the next hour of the trip, the driver increased the speed by 10%. How far did the car travel in the l
The driver slams on the brakes and goes from 165 mph to 85 mph in 4 seconds. What is the acceleration of the car?
Why did king William introduced forest laws?
what did you learn about Starr and kahili's history together?
The function a * b is defined as a * b = 2a - 3a + ab. If a * 2 = 14, find a.
Lee el párato y escoge la mejor respuesta. Read the paragraph and select the best answer Estas obras, que el museo londinense expondrá en enero del año próximo,
What is 12 inches to 36 inches in percent of change?
Math: Brainliest for right answer!!