# Java.lang.Character.getNumericValue() Method

## Description

The java.lang.Character.getNumericValue(int codePoint) returns the int value that the specified character (Unicode code point) represents. For example, the character '\u216C' (the Roman numeral fifty) will return an int with a value of 50.

The letters A-Z in their uppercase ('\u0041' through '\u005A'), lowercase ('\u0061' through '\u007A'), and full width variant ('\uFF21' through '\uFF3A' and '\uFF41' through '\uFF5A') forms have numeric values from 10 through 35. This is independent of the Unicode specification, which does not assign numeric values to these char values.

If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.

## Declaration

Following is the declaration for java.lang.Character.getNumericValue() method

```public static int getNumericValue(int codePoint)
```

## Parameters

codePoint − the character (Unicode code point) to be converted

## Return Value

This method returns the numeric value of the character, as a nonnegative int value; -2 if the character has a numeric value that is not a nonnegative integer; -1 if the character has no numeric value.

NA

## Example

The following example shows the usage of lang.Character.getNumericValue() method.

```package com.tutorialspoint;

import java.lang.*;

public class CharacterDemo {

public static void main(String[] args) {

// create 2 int primitives cp1, cp2
int cp1, cp2;

// assign values to cp1, cp2
cp1 = 0x0068;
cp2 = 0xff30;

// create 2 int primitives i1, i2
int i1, i2;

// assign numeric values of cp1, cp2 to i1, i2
i1 = Character.getNumericValue(cp1);
i2 = Character.getNumericValue(cp2);

String str1 = "Numeric value of code point cp1 is " + i1;
String str2 = "Numeric value of code point cp2 is " + i2;

// print i1, i2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
```

Let us compile and run the above program, this will produce the following result −

```Numeric value of code point cp1 is 17
Numeric value of code point cp2 is 25
```
java_lang_character.htm
{"ft_lang_label":"__label__en","ft_lang_prob":0.6406318,"math_prob":0.9704034,"size":2018,"snap":"2020-45-2020-50","text_gpt3_token_len":508,"char_repetition_ratio":0.17179742,"word_repetition_ratio":0.06984127,"special_character_ratio":0.271556,"punctuation_ratio":0.1462141,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98420066,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-30T06:53:35Z\",\"WARC-Record-ID\":\"<urn:uuid:8395d264-56b4-44e2-976c-7e5985068042>\",\"Content-Length\":\"27852\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:00dcbacb-b324-4fec-ac16-aa877d512415>\",\"WARC-Concurrent-To\":\"<urn:uuid:53234f4e-a18b-472b-b121-65a08a47c2b7>\",\"WARC-IP-Address\":\"72.21.91.42\",\"WARC-Target-URI\":\"https://www.tutorialspoint.com/java/lang/character_getnumericvalue_codepoint.htm\",\"WARC-Payload-Digest\":\"sha1:AG2DPFDQQ65L25IZYMBRXGQFMSLWELNR\",\"WARC-Block-Digest\":\"sha1:4G4EYNPT35FWRTICOFG4AJ7H6TTBT7NY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107909746.93_warc_CC-MAIN-20201030063319-20201030093319-00157.warc.gz\"}"}