Java Character example to get ASCII or unicode value of the character using codePointAt


public static int codePointAt(char[] a,int index)

Returns the code point at the given index of the char array. If the char value at     the given index in the char array is in the high-surrogate range, the following     index is less than the length of the char array, and the char value at the     following index is in the low-surrogate range, then the supplementary code     point corresponding to this surrogate pair is returned. Otherwise, the char value     at the given index is returned


Program:

package com.candidjava;

public class CharacterCodePointAt
{
public static void main(String[] args)
{
char[] c ={ 'a', 'b', 'c', 'd', 'e' };
int res, index = 0;
res = Character.codePointAt(c, index);

String str = "Unicode code point is " + res;
System.out.println( str );
}
}

Output:

    Unicode code point is 97


Description:

This method returns the Unicode code point at the given index.   


Parameters:

    a - the char array
    index - the index to the char values (Unicode code units) in the char array to be     converted


Returns:
    the Unicode code point at the given index


Throws:
    NullPointerException - if a is null.
    IndexOutOfBoundsException - if the value index is negative or not less than the     length of the char array.




Comments


©candidjava.com