List of usage examples for java.lang Integer Integer
@Deprecated(since = "9") public Integer(String s) throws NumberFormatException
From source file:Main.java
public static void addIntPair(Map map, Object key, int value1, int value2) { Object o = map.get(key);// ww w . j av a 2 s .co m List pair; if (o == null) { pair = new ArrayList(); pair.add(new Integer(value1)); pair.add(new Integer(value2)); map.put(key, pair); } else { pair = (List) o; List newPair = new ArrayList(); int new1 = ((Integer) pair.get(0)).intValue() + value1; int new2 = ((Integer) pair.get(1)).intValue() + value2; newPair.add(new Integer(new1)); newPair.add(new Integer(new2)); map.put(key, newPair); } }
From source file:Main.java
static int getMajorVersionNumberInternal(String version) { if (!version.equals("@" + "version" + "@")) { try {/*w ww . j a va 2 s.c o m*/ int firstDot = version.indexOf("."); String majorStr = version.substring(0, firstDot); return new Integer(majorStr).intValue(); } catch (NumberFormatException nfe) { } } // in case this is a mainline version or NFE was caught (strange) return 2; }
From source file:Main.java
public static SortedSet reverseSortedSet(int[] ints) { TreeSet sortedSet = new TreeSet(Collections.reverseOrder()); for (int i = 0; i < ints.length; i++) { sortedSet.add(new Integer(ints[i])); }/*from w w w . j av a 2s. c o m*/ return sortedSet; }
From source file:Main.java
public static void getComponentTreePosition(Component component, ArrayList position) { if (component.getParent() == null) { return;//from w w w.ja v a 2 s . c o m } getComponentTreePosition(component.getParent(), position); position.add(new Integer(component.getParent().getComponentCount() - getComponentIndex(component))); }
From source file:Main.java
public static int dptopx(Context ctxt, String dp) { return dptopx(ctxt, new Integer(dp)); }
From source file:Set2.java
public static Set fill(Set a, int size) { for (int i = 0; i < size; i++) a.add(new Integer(i)); return a;/*from ww w . j ava2 s . c o m*/ }
From source file:Main.java
public static List<Integer> addAll(List<Integer> in, int[] s) { for (int i : s) in.add(new Integer(i)); return in;/* w w w . ja v a2 s .co m*/ }
From source file:Main.java
public static Hashtable contarElementos(Vector list) { Hashtable hash = new Hashtable(); for (int i = 0; i < list.size(); i++) { Object key = list.elementAt(i); if (hash.containsKey(key)) { Integer qtde = new Integer(((Integer) hash.get(key)).intValue() + 1); hash.put(key, qtde);/* w w w . j ava 2 s . c o m*/ } else { hash.put(key, new Integer(1)); } } return hash; }
From source file:Main.java
public static int[] stringToIntArray(String s) { if (s == null || s.equals("")) { return new int[0]; }/*from w w w .j a v a 2 s . c o m*/ List<Integer> v = new ArrayList<Integer>(); String[] sa = s.split(";"); for (int i = 0; i < sa.length; i++) { try { v.add(new Integer(sa[i])); } catch (NumberFormatException e) { } } int[] ia = new int[v.size()]; for (int i = 0; i < ia.length; i++) { ia[i] = v.get(i).intValue(); } return ia; }
From source file:Main.java
public static Integer getInteger(JTextField txt, Integer defaultVal) { String str = txt.getText();//from w w w. j a v a 2 s. c o m if (str.trim().length() <= 0) return defaultVal; int val = 0; try { val = Integer.parseInt(str); } catch (NumberFormatException ex) { } return new Integer(val); }