-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_13_resulting_datatype.java
More file actions
29 lines (27 loc) · 1.31 KB
/
_13_resulting_datatype.java
File metadata and controls
29 lines (27 loc) · 1.31 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
public class _13_resulting_datatype {
public static void main(String[] args) {
byte b = 23;
short s = 246;
int i = 44;
long l = 7779;
char c = 'a';
float f = 23.04f;
double d = 43.42;
int bs = b+s; // byte + short -> returns int type
int si = s+i; // short + int -> returns int type
float lf = l+f; // long + float -> returns float type
float If = i+f; // int + float -> returns float type
int ci = c+i; // char + int -> returns int type
int cs = c+s; // char + short -> returns short type
double ld = l+d; // long + double -> returns double type
double fd = f+d; // float + double -> returns double type
System.out.println(bs); // byte + short -> int
System.out.println(si); // short + int -> int
System.out.println(lf); // long + float -> float
System.out.println(If); // int + float -> float
System.out.println(ci); // char + int -> int
System.out.println(cs); // char + short -> short
System.out.println(ld); // long + double -> double
System.out.println(fd); // float + double -> double
}
}