1、ISO-639 定义了语言代码, Common ISO-639 Language Codes
而ISO-3166定义了国家代码 ,Common ISO-3166 Country Codes
2、boxing 问题:
(from JSR 5.1.7): If the value p being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2.
因此,下面一个例子
AutoBoxing.java
import java.util.*;
public class AutoBoxing
{
public static void main(String [] args)
{
List<Integer> bigs = Arrays.asList(100, 200, 300);
assert sumInteger(bigs) == sum(bigs);
assert sumInteger(bigs) != sumInteger(bigs);
List<Integer> smalls = Arrays.asList(1, 2, 3);
assert sumInteger(smalls) == sum(smalls);
assert sumInteger(smalls) == sumInteger(smalls);
for (int i=-129; i<129; i++)
{
Integer small_1 = i;
Integer small_2 = i;
System.out.println((small_1 == small_2) + " " + i);
}
}
public static int sum(List<Integer> ints)
{
int s = 0;
for (int n : ints)
s += n;
return s;
}
public static Integer sumInteger(List<Integer> ints)
{
Integer s = 0;
for (Integer n : ints)
s += n;
return s;
}
}而其运行结果为:
运行结果
false -129
true -128
true -127
true -126
true -125
true -124
true -123
true -122
true -121
true -120
true -119
true -118
true -117
true -116
true -115
true -114
true -113
true -112
true -111
true -110
true -109
true -108
true -107
true -106
true -105
true -104
true -103
true -102
true -101
true -100
true -99
true -98
true -97
true -96
true -95
true -94
true -93
true -92
true -91
true -90
true -89
true -88
true -87
true -86
true -85
true -84
true -83
true -82
true -81
true -80
true -79
true -78
true -77
true -76
true -75
true -74
true -73
true -72
true -71
true -70
true -69
true -68
true -67
true -66
true -65
true -64
true -63
true -62
true -61
true -60
true -59
true -58
true -57
true -56
true -55
true -54
true -53
true -52
true -51
true -50
true -49
true -48
true -47
true -46
true -45
true -44
true -43
true -42
true -41
true -40
true -39
true -38
true -37
true -36
true -35
true -34
true -33
true -32
true -31
true -30
true -29
true -28
true -27
true -26
true -25
true -24
true -23
true -22
true -21
true -20
true -19
true -18
true -17
true -16
true -15
true -14
true -13
true -12
true -11
true -10
true -9
true -8
true -7
true -6
true -5
true -4
true -3
true -2
true -1
true 0
true 1
true 2
true 3
true 4
true 5
true 6
true 7
true 8
true 9
true 10
true 11
true 12
true 13
true 14
true 15
true 16
true 17
true 18
true 19
true 20
true 21
true 22
true 23
true 24
true 25
true 26
true 27
true 28
true 29
true 30
true 31
true 32
true 33
true 34
true 35
true 36
true 37
true 38
true 39
true 40
true 41
true 42
true 43
true 44
true 45
true 46
true 47
true 48
true 49
true 50
true 51
true 52
true 53
true 54
true 55
true 56
true 57
true 58
true 59
true 60
true 61
true 62
true 63
true 64
true 65
true 66
true 67
true 68
true 69
true 70
true 71
true 72
true 73
true 74
true 75
true 76
true 77
true 78
true 79
true 80
true 81
true 82
true 83
true 84
true 85
true 86
true 87
true 88
true 89
true 90
true 91
true 92
true 93
true 94
true 95
true 96
true 97
true 98
true 99
true 100
true 101
true 102
true 103
true 104
true 105
true 106
true 107
true 108
true 109
true 110
true 111
true 112
true 113
true 114
true 115
true 116
true 117
true 118
true 119
true 120
true 121
true 122
true 123
true 124
true 125
true 126
true 127
false 128
应尽量使用equals()而不是 == 来应用于诸如 Integer, String之类的比较
而ISO-3166定义了国家代码 ,Common ISO-3166 Country Codes
2、boxing 问题:
(from JSR 5.1.7): If the value p being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2.
因此,下面一个例子
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
import java.util.*;
public class AutoBoxing
{
public static void main(String [] args)
{
List<Integer> bigs = Arrays.asList(100, 200, 300);
assert sumInteger(bigs) == sum(bigs);
assert sumInteger(bigs) != sumInteger(bigs);
List<Integer> smalls = Arrays.asList(1, 2, 3);
assert sumInteger(smalls) == sum(smalls);
assert sumInteger(smalls) == sumInteger(smalls);
for (int i=-129; i<129; i++)
{
Integer small_1 = i;
Integer small_2 = i;
System.out.println((small_1 == small_2) + " " + i);
}
}
public static int sum(List<Integer> ints)
{
int s = 0;
for (int n : ints)
s += n;
return s;
}
public static Integer sumInteger(List<Integer> ints)
{
Integer s = 0;
for (Integer n : ints)
s += n;
return s;
}
}
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
false -129
true -128
true -127
true -126
true -125
true -124
true -123
true -122
true -121
true -120
true -119
true -118
true -117
true -116
true -115
true -114
true -113
true -112
true -111
true -110
true -109
true -108
true -107
true -106
true -105
true -104
true -103
true -102
true -101
true -100
true -99
true -98
true -97
true -96
true -95
true -94
true -93
true -92
true -91
true -90
true -89
true -88
true -87
true -86
true -85
true -84
true -83
true -82
true -81
true -80
true -79
true -78
true -77
true -76
true -75
true -74
true -73
true -72
true -71
true -70
true -69
true -68
true -67
true -66
true -65
true -64
true -63
true -62
true -61
true -60
true -59
true -58
true -57
true -56
true -55
true -54
true -53
true -52
true -51
true -50
true -49
true -48
true -47
true -46
true -45
true -44
true -43
true -42
true -41
true -40
true -39
true -38
true -37
true -36
true -35
true -34
true -33
true -32
true -31
true -30
true -29
true -28
true -27
true -26
true -25
true -24
true -23
true -22
true -21
true -20
true -19
true -18
true -17
true -16
true -15
true -14
true -13
true -12
true -11
true -10
true -9
true -8
true -7
true -6
true -5
true -4
true -3
true -2
true -1
true 0
true 1
true 2
true 3
true 4
true 5
true 6
true 7
true 8
true 9
true 10
true 11
true 12
true 13
true 14
true 15
true 16
true 17
true 18
true 19
true 20
true 21
true 22
true 23
true 24
true 25
true 26
true 27
true 28
true 29
true 30
true 31
true 32
true 33
true 34
true 35
true 36
true 37
true 38
true 39
true 40
true 41
true 42
true 43
true 44
true 45
true 46
true 47
true 48
true 49
true 50
true 51
true 52
true 53
true 54
true 55
true 56
true 57
true 58
true 59
true 60
true 61
true 62
true 63
true 64
true 65
true 66
true 67
true 68
true 69
true 70
true 71
true 72
true 73
true 74
true 75
true 76
true 77
true 78
true 79
true 80
true 81
true 82
true 83
true 84
true 85
true 86
true 87
true 88
true 89
true 90
true 91
true 92
true 93
true 94
true 95
true 96
true 97
true 98
true 99
true 100
true 101
true 102
true 103
true 104
true 105
true 106
true 107
true 108
true 109
true 110
true 111
true 112
true 113
true 114
true 115
true 116
true 117
true 118
true 119
true 120
true 121
true 122
true 123
true 124
true 125
true 126
true 127
false 128