-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpressionTypeExample.java
More file actions
40 lines (28 loc) · 943 Bytes
/
Copy pathExpressionTypeExample.java
File metadata and controls
40 lines (28 loc) · 943 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
package basic.operators;
public class ExpressionTypeExample {
public static void main(String[] args) {
byte b = 1;
short s = 1;
int i = 1;
long l = 1;
float f = 1.0F;
double d = 1.0;
char c = 1;
int intExpressionType = b + b; // int
System.err.println(intExpressionType);
int intExpressionType2 = s + s; // int
System.out.println(intExpressionType2);
int intExpressionType3 = b + i + c; // int
System.out.println(intExpressionType3);
long longExpressionType = i + l; // long
System.out.println(longExpressionType);
float floatExpressionType = l + f; // float
System.out.println(floatExpressionType);
double doubleExpressionType = f + d; // double
System.out.println(doubleExpressionType);
System.out.println(10 / 3); // 3
System.out.println(10.0 / 3); // 3.3333333333333335
System.out.println("Hello " + 1); // Hello 1
System.out.println("Hello " + null); // Hello null
}
}