-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.java
More file actions
43 lines (27 loc) · 1021 Bytes
/
Copy pathconvert.java
File metadata and controls
43 lines (27 loc) · 1021 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
39
40
41
42
43
import java.util.*;
public class convert
{
public static void main(String[] args)
{
/* COVERT NUMERIC CHARACTERS TO INTEGERS */
System.out.println(Character.getNumericValue('3')); /* Method 1 */
System.out.println(Integer.parseInt("3")); /* Method 2 */
System.out.println('3' - '0'); /* Method 3 */
System.out.println();
/* GET ASCII VALUE OF CHAR */
/* Method 1 */
System.out.println((int)'c');
/* Method 2 */
char ch = 'c';
int num = ch;
System.out.println(num);
/* CONVERT ASCII VALUE TO CHAR */
System.out.println((char)97);
/* CONVERT ANY DATATYPE TO STRING */
System.out.println(String.valueOf(3));
System.out.println(String.valueOf('3'));
/* STRING TO CHAR ARRAY */
String s = "Sharvil";
char[] sch = s.toCharArray();
}
}