proposed method selection precendece rules for numbers:
| byte | Byte | short | Short | int | Integer | long | Long | BigInteger | float | Float | double | Double | BigDecimal | Number | Object | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| Byte | 1 | 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| short | |
|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| Short | |
|
1 | 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| int | |
|
|
|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| Integer | |
|
|
|
1 | 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| long | |
|
|
|
|
|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| Long | |
|
|
|
|
|
1 | 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| BigInteger | |
|
|
|
|
|
|
|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| float | |
|
|
|
|
|
|
|
|
0 | 1 | 2 | 3 | 4 | 5 | 6 |
| Float | |
|
|
|
|
|
|
|
|
1 | 0 | 2 | 3 | 4 | 5 | 6 |
| double | |
|
|
|
|
|
|
|
|
|
|
0 | 1 | 2 | 3 | 4 |
| Double | |
|
|
|
|
|
|
|
|
|
|
1 | 0 | 2 | 3 | 4 |
| BigDecimal | |
|
|
|
|
|
|
|
|
|
|
|
|
0 | 1 | 2 |
| Number | |
|
|
|
|
|
|
|
|
|
|
|
|
|
0 | 1 |
| Object | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0 |
= not possible. A lower number means that type is prefered over a type with a higher number.
for example calling a method foo with an argument of type Short, and I have these methods:
def foo(long y){}
def foo(BigDecimal y){}
Then the method with the long is used, because it gets the number 4 and BigDecimal 11.
Labels
(None)
