Java String CharAt Example
String class CharAt method example
String class CharAt method example. This example shows you how to use CharAt method of String Class.This method Returns the Character at Specified index.
Syntax:-charAt(int index)
Here is the Code:-
/**
* @(#) Characterstring.java
*Program Shows a class Displaying the Character at Specified Position .
* @Version 01-May-2008
* @author Rose India Team
*/
class Characterstring
{
public static void main(String[] args)
{
// Declaration of String
String a="Welcome to Rose india";
//Displays the Actual String declared above
System.out.println("GIVEN STRING IS="+a);
// Returns the character at the specified index i.e 3
System.out.println("character at position 3 IN THE STRING IS="+a.charAt(3));
}
} |
|