-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatatypeLiteralConvertion.java
More file actions
55 lines (37 loc) · 1.38 KB
/
DatatypeLiteralConvertion.java
File metadata and controls
55 lines (37 loc) · 1.38 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
public class DatatypeLiteralConvertion {
public static void main(String[] args) {
byte b=23; //1 byte,Range calculation 2pow7 to 2pow7-1
short c=22; //2 byte
int a=12;//4 byte
long d=40; //8byte
float e=10.2f; //4 byte
double f=22;//8byte
double g=10e10;
int h=0b1111;//binary
int i=0X7E;//hexa
int j=100;
byte k=(byte)j;
int z=257;
byte y = (byte) z;//explicit conversion 257%256
char l='c';
c++;
boolean u=true;
System.out.println(l);
System.out.println(b);
System.out.println(h);
System.out.println(k);
System.out.println(y);
}
}
/*
Literal:
A literal is a value that is directly written in the source code of a program.
Data Type:
A data type in Java specifies the type of data that a variable can hold.
It defines the characteristics and operations that can be performed on the variable.
Examples of data types in Java include int, double, boolean, char, etc.
Each data type has a specific range of values and occupies a specific amount of memory.
Variable:
A variable is a named storage location in a program that holds a value of a specific data type.
It is used to store and manipulate data during program execution.
Variables must be declared with a specific data type before they can be used.*/