Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

String indexOf() Method

In this section, you will get the detailed explanation about the indexOf() method of String class.

String indexOf() Method

                         

In this section, you will get the detailed explanation about the indexOf() method of String class. We are going to use indexOf() method of String class in Java. The description of the code is given below for the usage of the method.

Description of the code:

Here, you will get to know about the indexOf() method through the following java program. In the program code given below, we have taken a String. To find the index of any character we have applied indexOf(); method and then we have passed the character in that to find its index as shown in the output.

The code of the program is given below: 

public class stringDemo{
  public static void main(String[] argsthrows Exception{
    String color = "bluegrey";
    int index = color.indexOf('e')
    System.out.println(index);
  }
}

Output of the program:

C:\unique>javac stringDemo.java

C:\unique>java stringDemo
3

C:\unique>

Download this example.

 

                         

» View all related tutorials
Related Tags: java c string class method get int index program to ram e il use indexof in no as m nt

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

4 comments so far (
post your own) View All Comments Latest 10 Comments:

in util package i have so many doubts.by using this i can able to clear some of my doubts

Posted by kumaran on Saturday, 10.11.08 @ 18:19pm | #81018

may I ask some specific questions?do you know the string class method?and their examples?just lyk ex."index method"....can you please give me the answers of my question?thanks .....

Posted by LJ on Sunday, 09.21.08 @ 11:34am | #80576

anyone can easily understand this. very superb

Posted by rathidevi on Monday, 08.25.08 @ 11:59am | #74977

how to read text document and only display string inside the bracket only.

Posted by dYeeLa on Wednesday, 05.14.08 @ 07:30am | #59760

 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.