Selasa, 13 Maret 2012

java.lang.String.charAt(int index)


The char at the given index within the String.
// string_charat.jsl

public class Program
{
    public static void main(String[] args)
    {
        String str = "Hello, World!";

        // Get the character at positions 0 and 12.
        int index1 = str.charAt(0);
        int index2 = str.charAt(12);

        // Print out the results.
        System.out.println("The character at position 0 is " +
            (char)index1);
        System.out.println("The character at position 12 is " +
            (char)index2);
    }
}

/*
Output:
The character at position 0 is H
The character at position 12 is !
*/

Reference

java.lang.String

1 komentar:

Chord The Day's Of Father-Superman Is Dead

Intro: G5 . . . . E5 4x E5 B5 E5 B5 A5 B5 C5 D5 E5 E5 B5 E5 B5 A5 B5 C5 E5 B5 E5 B5 A5 B5 C5 D5 E5 2x E5 When the morning comes to spot...