-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryGap.java
More file actions
38 lines (24 loc) · 803 Bytes
/
Copy pathBinaryGap.java
File metadata and controls
38 lines (24 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package quiz;
import java.io.UnsupportedEncodingException;
/**
* @Author : yion
* @Date : 2017. 3. 23.
* @Description :
*/
public class BinaryGap {
public static void main(String[] args) throws UnsupportedEncodingException {
int x = 2;
// decimal to binary
String binaryString = Integer.toBinaryString(x);
// decimal to hexadecimal
String hexString = Integer.toHexString(x);
// ASCII Code to String
String charAscII = new Character((char) x).toString();
System.out.println("binary : " + binaryString);
System.out.println("hex : " + hexString);
System.out.println("ASCII : " + charAscII);
String str = "1226#24#";
int val = str.charAt(0) - '0';
System.out.println(val);
}
}