The java.lang.Character.digit(char ch, int radix) returns the numeric value of the character ch in the specified radix.
Syntax:public static int digit(char ch, int radix)
Example:/* java example */
import java.lang.*;
public class CharacterDemo {
public static void main(String[] args) {
// create 2 character primitives ch1, ch2
char ch1, ch2;
// assign values to ch1, ch2
ch1 = '9';
ch2 = '5';
// create 2 int primitives i1, i2
int i1, i2;
// assign numeric value of ch1, ch2 to i1, i2 using radix
i1 = Character.digit(ch1, 2);
i2 = Character.digit(ch2, 10);
String str1 = "Numeric value of " + ch1 + " in radix 2 is " + i1;
String str2 = "Numeric value of " + ch2 + " in radix 10 is " + i2;
// print i1, i2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
License.
All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 648 / 158764312. Delta: 0.21600 с