Example usage for java.lang Integer Integer

List of usage examples for java.lang Integer Integer

Introduction

In this page you can find the example usage for java.lang Integer Integer.

Prototype

@Deprecated(since = "9")
public Integer(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Integer object that represents the int value indicated by the String parameter.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    Vector vector = new Vector();
    vector.addElement(new Integer(5));
    vector.addElement(new Float(-14.14f));

    System.out.println(vector);/*from  w  w  w .  ja  v a 2 s  .  co m*/

    String s = new String("String to be inserted");
    vector.insertElementAt(s, 1);
    System.out.println(vector);

    vector.removeElementAt(2);
    System.out.println(vector);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Constructor con = Point.class.getConstructor(new Class[] { int.class, int.class });
    Point obj = (Point) con.newInstance(new Object[] { new Integer(1), new Integer(1) });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Constructor con = java.awt.Point.class.getConstructor(new Class[] { int.class, int.class });
    java.awt.Point obj = (java.awt.Point) con.newInstance(new Object[] { new Integer(123), new Integer(123) });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

    Object o1 = new Integer(123);
    Object o2 = new Integer(123);
    objMap.put(o1, "first");
    objMap.put(o2, "from java2s.com");

    Object v1 = objMap.get(o1);/*  w  w  w.j a  v  a  2s  .  c o m*/
    System.out.println(v1);
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    // create a set view
    Set<Object> nset = objMap.keySet();

    System.out.println("Set view is: " + nset);
}

From source file:MainClass.java

public static void main(String[] args) {
    String data;/*from w ww  . ja v  a 2 s  .c  om*/
    String msg;

    Hashtable h = new Hashtable(20);

    System.out.println(h.put("one", new Integer(1)));
    System.out.println(h.put("name", "A"));
    System.out.println(h.put("date", new Date()));
    System.out.println(h.put("one", new Integer(4)));

    Enumeration e = h.keys();
    while (e.hasMoreElements())
        System.out.println(e.nextElement());

    e = h.elements();
    while (e.hasMoreElements())
        System.out.println(e.nextElement());
}

From source file:HashMapExample.java

public static void main(String[] args) {
    Map<Integer, String> map = new HashMap<Integer, String>();

    map.put(new Integer(1), "One");
    map.put(new Integer(2), "Two");
    map.put(new Integer(3), "Three");
    map.put(new Integer(4), "Four");
    map.put(new Integer(5), "Five");

    System.out.println("Map Values Before: ");
    Set keys = map.keySet();//from  w w w  .j a v  a  2  s .  c  om
    for (Iterator i = keys.iterator(); i.hasNext();) {
        Integer key = (Integer) i.next();
        String value = (String) map.get(key);
        System.out.println(key + " = " + value);
    }

    System.out.println("\nRemove element with key 6");
    map.remove(new Integer(6));

    System.out.println("\nMap Values After: ");
    keys = map.keySet();
    for (Iterator i = keys.iterator(); i.hasNext();) {
        Integer key = (Integer) i.next();
        String value = (String) map.get(key);
        System.out.println(key + " = " + value);
    }
}

From source file:Main.java

public static void main(String args[]) {
    Vector v = new Vector(5);
    for (int i = 0; i < 10; i++) {
        v.add(0, i);/*from w w w.  j a va 2s  . c om*/
    }
    System.out.println(v.capacity());
    System.out.println(v);

    v.remove(new Integer(9));

    v.removeElement(new Integer(2));

    System.out.println(v);
    System.out.println(v.capacity());

}

From source file:ClosureExample.java

public static void main(String args[]) {
    Closure ifClosure = ClosureUtils.ifClosure(PredicateUtils.equalPredicate(new Integer(20)),
            ClosureUtils.nopClosure(), ClosureUtils.exceptionClosure());
    ifClosure.execute(new Integer(20));
    //      ifClosure.execute(new Integer(30));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

    Object o1 = new Integer(123);
    Object o2 = new Integer(123);
    objMap.put(o1, "first");
    objMap.put(o2, "from java2s.com");

    Object v1 = objMap.get(o1);/*from   w w  w .  j  av  a2  s .co m*/
    System.out.println(v1);
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    System.out.println("Value at key '2' is: " + objMap.get(o1));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

    Object o1 = new Integer(123);
    Object o2 = new Integer(123);
    objMap.put(o1, "first");
    objMap.put(o2, "from java2s.com");

    Object v1 = objMap.get(o1);/* w  ww .  jav a  2 s  .com*/
    System.out.println(v1);
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    Map<Object, Object> objMap1 = new IdentityHashMap<Object, Object>();

    System.out.println(objMap1.equals(objMap));
}