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 main(String[] args) { TreeSet<Integer> tSet = new TreeSet<Integer>(); tSet.add(new Integer("1")); tSet.add(new Integer("2")); tSet.add(new Integer("3")); System.out.println("TreeSet before removal : " + tSet); tSet.clear();// www. j a va 2s . c o m System.out.println("TreeSet after removal : " + tSet); System.out.println("Is TreeSet empty ? " + tSet.isEmpty()); }
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); Object[] objArray = hSet.toArray(); for (Object obj : objArray) System.out.println(obj);//from w w w. ja v a 2 s. c om }
From source file:Main.java
public static void main(String[] args) { Integer[] arrayToSort = new Integer[] { new Integer(5), new Integer(89), new Integer(16), new Integer(2) }; Arrays.sort(arrayToSort, Collections.reverseOrder()); for (Integer i : arrayToSort) { System.out.println(i.intValue()); }/*from w w w. ja v a 2 s.c o m*/ }
From source file:Main.java
public static void main(String[] args) { ArrayList<Integer> al = new ArrayList<Integer>(); al.add(new Integer(1)); al.add(new Integer(2)); al.add(new Integer(3)); al.add(new Integer(4)); al.add(new Integer(5)); System.out.println("contents of al : " + al); Object ia[] = al.toArray(); // get array int sum = 0;// ww w . j a v a 2 s . c o m for (int i = 0; i < ia.length; i++) { sum += ((Integer) ia[i]).intValue(); } System.out.println("Sum is :" + sum); }
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); System.out.println(hSet);// w ww. j a va 2 s.c om hSet.clear(); System.out.println(hSet); System.out.println(hSet.isEmpty()); }
From source file:Main.java
public static void main(String[] args) { HashSet<Integer> hSet = new HashSet<Integer>(); hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); System.out.println(hSet);//from w w w . j a v a2 s . c om boolean blnRemoved = hSet.remove(new Integer("2")); System.out.println(blnRemoved); System.out.println(hSet); }
From source file:Main.java
public static void main(String[] argv) { List<Integer> intlist = new ArrayList<Integer>(); intlist.add(new Integer(123)); }
From source file:Main.java
public static void main(String[] argv) { List<Number> numlist = new ArrayList<Number>(); numlist.add(new Integer(123)); numlist.add(new Float(123)); }
From source file:Main.java
public static void main(String[] args) { LinkedHashSet<Integer> lhashSet = new LinkedHashSet<Integer>(); lhashSet.add(new Integer("1")); lhashSet.add(new Integer("2")); lhashSet.add(new Integer("3")); System.out.println(lhashSet); }
From source file:Main.java
public static void main(String[] args) { LinkedHashSet<Integer> lhashSet = new LinkedHashSet<Integer>(); lhashSet.add(new Integer("1")); lhashSet.add(new Integer("2")); lhashSet.add(new Integer("3")); LinkedHashSet<Integer> lhashSet2 = new LinkedHashSet<Integer>(lhashSet); }