25.02.2017 Views

java_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java<br />

Example<br />

import <strong>java</strong>.io.*;<br />

public class Test {<br />

}<br />

public static void main(String args[]) {<br />

String Str = new String("Welcome to Tutorialspoint.com");<br />

System.out.print("Found Index :" );<br />

System.out.println(Str.indexOf( 'o' ));<br />

}<br />

This will produce the following result:<br />

Found Index :4<br />

Java – String indexOf(int ch, int fromIndex) Method<br />

Description<br />

This method returns the index within this string of the first occurrence of the specified<br />

character, starting the search at the specified index or -1, if the character does not occur.<br />

Syntax<br />

Here is the syntax of this method:<br />

public int indexOf(int ch, int fromIndex)<br />

Parameters<br />

Here is the detail of parameters:<br />

<br />

<br />

ch -- a character.<br />

fromIndex -- the index to start the search from.<br />

Return Value<br />

<br />

See the description.<br />

159

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!