-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsing Type-Casting
More file actions
60 lines (50 loc) · 1.25 KB
/
Copy pathUsing Type-Casting
File metadata and controls
60 lines (50 loc) · 1.25 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
PrintAsciiValueExample1.java
public class PrintAsciiValueExample3
{
public static void main(String[] args)
{
//characters whose ASCII value to be found
char ch1 = 'a';
char ch2 = 'b';
//casting or converting a charter into int type
int ascii1 = (int) ch1;
int ascii2 = (int) ch2;
System.out.println("The ASCII value of " + ch1 + " is: " + ascii1);
System.out.println("The ASCII value of " + ch1 + " is: " + ascii2);
}
}
PrintAsciiValueExample2.java
import java.util.Scanner;
public class PrintAsciiValueExample4
{
public static void main(String args[])
{
System.out.print("Enter a character: ");
Scanner sc = new Scanner(System.in);
char chr = sc.next().charAt(0);
int asciiValue = chr;
System.out.println("ASCII value of " +chr+ " is: "+asciiValue);
}
}
AsciiValueOfAllChracters.java
public class AsciiValueOfAllChracters
{
public static void main(String[] args)
{
for(int i = 0; i <= 255; i++)
{
System.out.println(" The ASCII value of " + (char)i + " = " + i);
}
}
}
AsciiValueAtoZ.java
public class AsciiValueAtoZ
{
public static void main(String[] args)
{
for(int i = 65; i <= 90; i++)
{
System.out.println(" The ASCII value of " + (char)i + " = " + i);
}
}
}