forked from Jetos-Solutions/JetosSolutionsJavaExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimitive.java
More file actions
49 lines (32 loc) · 1.29 KB
/
Primitive.java
File metadata and controls
49 lines (32 loc) · 1.29 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
public class Primitive {
public static void main(String args[]) {
byte byteValue1 = 2;
byte byteValue2 = 4;
byte byteResult = (byte)(byteValue1 + byteValue2);
System.out.println("Byte: " + byteResult);
short shortValue1 = 2;
short shortValue2 = 4;
short shortResult = (short)(shortValue1 + shortValue2);
System.out.println("Short: " + shortResult);
int intValue1 = 2;
int intValue2 = 4;
int intResult = intValue1 + intValue2;
System.out.println("Int: " + intResult);
long longValue1 = 2L;
long longValue2 = 4L;
long longResult = longValue1 + longValue2;
System.out.println("Long: " + longResult);
float floatValue1 = 2.0f;
float floatValue2 = 4.0f;
float floatResult = floatValue1 + floatValue2;
System.out.println("Float: " + floatResult);
double doubleValue1 = 2.0;
double doubleValue2 = 4.0;
double doubleResult = doubleValue1 + doubleValue2;
System.out.println("Double: " + doubleResult);
boolean booleanValue = true;
System.out.println("Boolean: " + booleanValue);
char charValue = 'A';
System.out.println("Char: " + charValue);
}
}