1 19 20 package org.netbeans.lib.lexer; 21 22 28 29 public final class IntegerCache { 30 31 private static final int MAX_CACHED_INTEGER = 127; 33 34 private static final Integer [] cache = new Integer [MAX_CACHED_INTEGER + 1]; 35 36 public static Integer integer(int i) { 37 Integer integer; 38 if (i <= MAX_CACHED_INTEGER) { 39 integer = cache[i]; 40 if (integer == null) { 41 integer = Integer.valueOf(i); cache[i] = integer; } 44 45 } else { integer = new Integer (i); 47 } 48 return integer; 49 } 50 51 } 52 | Popular Tags |