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:Main.java

public static void main(String args[]) {
    Stack st = new Stack();
    System.out.println("stack: " + st);
    st.push(new Integer(42));
    System.out.println("push(" + 42 + ")");
    System.out.println("stack: " + st);

    System.out.print("pop -> ");
    Integer a = (Integer) st.pop();
    System.out.println(a);/*from  w w w  .j a  v  a 2 s  . c  om*/
    System.out.println("stack: " + st);

    try {
        st.pop();
    } catch (EmptyStackException e) {
        e.printStackTrace();
        System.out.println("empty stack");
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Stack st = new Stack();
    System.out.println("stack: " + st);
    st.push(new Integer(42));
    System.out.println("push(" + 42 + ")");
    System.out.println("stack: " + st);

    System.out.print("pop -> ");
    Integer a = (Integer) st.pop();
    System.out.println(a);/*from   w w w . ja  v a 2  s .co  m*/
    System.out.println("stack: " + st);

    try {
        st.pop();
    } catch (EmptyStackException e) {
        System.out.println("empty stack");
    }
}

From source file:Main.java

public static void main(String args[]) {
    Dictionary ht = new Hashtable();
    ht.put("a", "a");
    ht.put("b", new Double(2));
    ht.put("c", "b");
    ht.put("d", new Integer(30));
    show(ht);// w  ww  . ja va 2  s .  c  o  m
}

From source file:MainClass.java

public static void main(String args[]) {
    Hashtable ht = new Hashtable();
    ht.put("a", "a");
    ht.put("b", new Double(2));
    ht.put("c", "b");
    ht.put("d", new Integer(30));
    show(ht);/*from   www . j av  a2s.  c o  m*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String[] columns = { "Name", "Age" };

    Object[][] content = { { "R", new Integer(24) }, { "A", new Integer(25) }, { "J", new Integer(30) },
            { "A", new Integer(32) }, { "S", new Integer(27) } };

    JTable table = new JTable(content, columns);
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel jPanel = new JPanel(new GridLayout(2, 0));
    jPanel.setOpaque(true);/*from   w  ww . j  a  va  2s. c o  m*/
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    jPanel.add(new JScrollPane(table));
    /* Add the panel to the JFrame */
    frame.add(jPanel);
    /* Display the JFrame window */
    frame.pack();
    frame.setVisible(true);

    table.print();
}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<Integer> ids = new ArrayList<>();

    int total = ids.size(); // total will be zero

    System.out.println("ArrayList size is  " + total);
    System.out.println("ArrayList elements are   " + ids);

    ids.add(new Integer(10)); // Adding an Integer object.
    ids.add(20); // Autoboxing
    ids.add(30); // Autoboxing

    total = ids.size(); // total will be 3

    System.out.println("ArrayList size is  " + total);
    System.out.println("ArrayList elements are   " + ids);

    ids.clear();//from ww w. j a  v a 2 s.c  o  m

    total = ids.size(); // total will be 0
    System.out.println("ArrayList size is  " + total);
    System.out.println("ArrayList elements are   " + ids);
}

From source file:Stacks.java

public static void main(String[] args) {
    Stack stack = new Stack();
    for (int i = 0; i < 10; i++)
        stack.push(new Integer(i));
    System.out.println("stack = " + stack);
    // Treating a stack as a Vector:
    stack.addElement("The last line");
    System.out.println("element 5 = " + stack.elementAt(5));
    System.out.println("popping elements:");
    while (!stack.empty())
        System.out.println(stack.pop());
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println(new Vector().getClass().getPackage().getName());
    System.out.println(new ArrayList().getClass().getPackage().getName());
    System.out.println("Test String".getClass().getPackage().getName());
    System.out.println(new Integer(1).getClass().getPackage().getName());
}

From source file:WrappedClassApp.java

public static void main(String args[]) {
    Boolean b1 = new Boolean("TRUE");
    Boolean b2 = new Boolean("FALSE");
    System.out.println(b1.toString() + " or " + b2.toString());
    for (int j = 0; j < 16; ++j)
        System.out.print(Character.forDigit(j, 16));
    System.out.println();//  ww w.j  a  va2  s  . com
    Integer i = new Integer(Integer.parseInt("ef", 16));
    Long l = new Long(Long.parseLong("abcd", 16));
    long m = l.longValue() * i.longValue();
    System.out.println(Long.toString(m, 8));
    System.out.println(Float.MIN_VALUE);
    System.out.println(Double.MAX_VALUE);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Item bean = new Item();
    bean.setId(new Long(1));
    bean.setItemName("a");
    bean.setItemColour("Red");
    bean.setItemQuantities(new Integer(100));

    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("Bean.xml")));

    encoder.writeObject(bean);//from w w w  . j  a  v a  2s  .  co m
    encoder.close();
}