-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvarTypes.java
More file actions
48 lines (29 loc) · 989 Bytes
/
varTypes.java
File metadata and controls
48 lines (29 loc) · 989 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
44
45
46
47
48
public class varTypes {
public static void main(String[] args) {
//variable = structures that store data
/*-----Primitive Variables-----*/
//ram occupancy is known
byte bt = 10; // 1 byte on ram
short s = 10; // 2 byte on ram
int x = 10; // 4 byte on ram
long y = 10; // 8 byte on ram
double d = 10.5; // 4 byte on ram
float f = 10.5f; // 8 byte on ram
float f2 = (float) 10.6; // 8 byte on ram
char c = 'A'; // 2 byte on ram
boolean b = true; // 1 bit on ram
System.out.println(bt);
System.out.println(s);
System.out.println(x);
System.out.println(y);
System.out.println(d);
System.out.println(f);
System.out.println(f2);
System.out.println(c);
System.out.println(b);
/*-----Non-Primitive Variables-----*/
//ram occupancy is unknown
String st = "Eren"; // 2 byte for each char in string- 8 byte for Eren
System.out.println(st);
}
}