Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Beginners charAt() method in java

 
 

Share on Google+Share on Google+

charAt() method in java

Advertisement
In this section you will get detail about charAt() in java. This method comes in java.lang.String package. charAt() return the character at the given index within the string, index starting from 0. This method return the character at the specified index in the string.

charAt() method in java

In this section you will get detail about charAt() in java. This method comes in java.lang.String package. charAt() return the character at the given index within the string, index starting from 0. This method return the character at the specified index in the string.

Syntax:

public char charAt(int index)

index - index of the character  to be returned.

Example: A program  how to use charAt() method in java.

import java.lang.*;
class Demo
  {
    public static void main(String args[])
    {
	String s="welcome to rose india";
    char pos =s.charAt(3); // return the character at position 3rd
   System.out.println("character  at 3rd position is = "+pos);
     }
  } 

Output :  After compiling and executing the above program.

Download Source Code

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 10, 2013

Related Tutorials

Discuss: charAt() method in java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com