-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataTypes.java
64 lines (42 loc) · 1.47 KB
/
DataTypes.java
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
61
62
63
64
// Data types -> are of primitive and non-primitive
//primitive -> has four categories(general),
// int - natural numbers, whole numbers
// inside int we have byte, short, int, long
// float - point values
// in float we have, double
// these two are also called as number types
// characters - characters
// boolean - true and false
class DataTypes{
public static void main(String args[]){
// int k= 9;
// // byte by = 129; does not work
// byte by =127;
// short sh = 558;
// long l = 58854l;
// // float f= 5.8;
// float f = 5.8f;
// char c = 'k';
// boolean b = true;
}
}
// integer will have different sizes, in general we store in it
// integer -> int -< 4 bytes >-
// integer -> long -< 8 bytes >-
// integer -> short -< 2 bytes >-
// integer -> byte -< 1 byte >-
// // how do we calculate range is
// byte -1 byte -> -2raispower7 to 2raispower7 -1
// thats what we go -> -128 to 127
// float - 4 bytes
// double - 8 bytes (by default in java, greater range)
// double num = 5.6;
// float num = 5.6; // error its double
// float num = 5.6f // now no error this is float
// characters - 2 bytes here
// UNICODE - java , other languages (ASCII)
// char c = 'a'; // use single quotes for characters
// Boolean -> true or false
// bool b = false;
// bool b = true;
// later we see non-primitve data types