-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTypePromotionRule.java
More file actions
52 lines (46 loc) · 1.01 KB
/
TypePromotionRule.java
File metadata and controls
52 lines (46 loc) · 1.01 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
50
51
52
class Calc{
// int add(int x, int y) {
// System.out.println("Int");
// return x + y;
// }
// long add(long x, long y) {
// System.out.println("long");
// return x + y;
// }
// double add(double x, double y) {
// System.out.println("double");
// return x + y;
// }
int add(short x, short y) {
System.out.println("short");
return x + y;
}
int add(byte x, byte y) {
System.out.println("byte");
return x + y;
}
// int add(Integer x, Integer y) {
// System.out.println("Integer Wrapper");
// return x + y;
// }
long add(Long x, Long y) {
System.out.println("Long Wrapper");
return x + y;
}
// int add(int...x ) {
// System.out.println("int var args");
// return x.length;
// }
// int add(long...x ) {
// System.out.println("long var args");
// return x.length;
// }
}
public class TypePromotionRule {
public static void main(String[] args) {
// TODO Auto-generated method stub
Calc calc = new Calc();
// System.out.println(calc.add(1,2));
System.out.println(calc.add((short)1,(short)2));
}
}