1130 * equal to the value of:
1131 *
1132 * <blockquote>
1133 * {@code new Long(Long.parseLong(s))}
1134 * </blockquote>
1135 *
1136 * @param s the string to be parsed.
1137 * @return a {@code Long} object holding the value
1138 * represented by the string argument.
1139 * @throws NumberFormatException If the string cannot be parsed
1140 * as a {@code long}.
1141 */
1142 public static Long valueOf(String s) throws NumberFormatException
1143 {
1144 return Long.valueOf(parseLong(s, 10));
1145 }
1146
1147 private static class LongCache {
1148 private LongCache(){}
1149
1150 static final Long cache[] = new Long[-(-128) + 127 + 1];
1151
1152 static {
1153 for(int i = 0; i < cache.length; i++)
1154 cache[i] = new Long(i - 128);
1155 }
1156 }
1157
1158 /**
1159 * Returns a {@code Long} instance representing the specified
1160 * {@code long} value.
1161 * If a new {@code Long} instance is not required, this method
1162 * should generally be used in preference to the constructor
1163 * {@link #Long(long)}, as this method is likely to yield
1164 * significantly better space and time performance by caching
1165 * frequently requested values.
1166 *
1167 * This method will always cache values in the range -128 to 127,
1168 * inclusive, and may cache other values outside of this range.
1169 *
1170 * @param l a long value.
|
1130 * equal to the value of:
1131 *
1132 * <blockquote>
1133 * {@code new Long(Long.parseLong(s))}
1134 * </blockquote>
1135 *
1136 * @param s the string to be parsed.
1137 * @return a {@code Long} object holding the value
1138 * represented by the string argument.
1139 * @throws NumberFormatException If the string cannot be parsed
1140 * as a {@code long}.
1141 */
1142 public static Long valueOf(String s) throws NumberFormatException
1143 {
1144 return Long.valueOf(parseLong(s, 10));
1145 }
1146
1147 private static class LongCache {
1148 private LongCache(){}
1149
1150 static final Long[] cache = new Long[-(-128) + 127 + 1];
1151
1152 static {
1153 for(int i = 0; i < cache.length; i++)
1154 cache[i] = new Long(i - 128);
1155 }
1156 }
1157
1158 /**
1159 * Returns a {@code Long} instance representing the specified
1160 * {@code long} value.
1161 * If a new {@code Long} instance is not required, this method
1162 * should generally be used in preference to the constructor
1163 * {@link #Long(long)}, as this method is likely to yield
1164 * significantly better space and time performance by caching
1165 * frequently requested values.
1166 *
1167 * This method will always cache values in the range -128 to 127,
1168 * inclusive, and may cache other values outside of this range.
1169 *
1170 * @param l a long value.
|