java数据类型
java中有几种特殊的类型String, Array,Enum, 属于Object,派生出来的, 但是String可以做加法, 另外两个可以花括号定义初值;
primitive type(基本值类型) VS Object type(对象类型)
装包和拆包
/** * Returns an {@code Integer} instance representing the specified * {@code int} value. If a new {@code Integer} instance is not * required, this method should generally be used in preference to * the constructor {@link #Integer(int)}, as this method is likely * to yield significantly better space and time performance by * caching frequently requested values. * * This method will always cache values in the range -128 to 127, * inclusive, and may cache other values outside of this range. * * @param i an {@code int} value. * @return an {@code Integer} instance representing {@code i}. * @since 1.5 */ public static Integer valueOf(int i) { if (i >= IntegerCache.low && i <= IntegerCache.high) return IntegerCache.cache[i + (-IntegerCache.low)]; return new Integer(i); }
.valueOf () 两个进行比较可能等也可能不等。
另外在进行
数值初始化的时候数组可以直接输出值, 比如int[] 可以对某一个值输出0,
而int a; 直接使用会编译错误;