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

public static void main(String args[]) {
    JFrame frame = new JFrame("Formatted");
    Container contentPane = frame.getContentPane();
    JFormattedTextField ftf1 = new JFormattedTextField(new Integer(0));
    contentPane.add(ftf1, BorderLayout.NORTH);
    JFormattedTextField ftf2 = new JFormattedTextField(new Date());
    contentPane.add(ftf2, BorderLayout.SOUTH);
    frame.setSize(200, 100);/* w  ww. j a va 2s. c om*/
    frame.show();
}

From source file:Main.java

public static void main(String[] args) {
    LinkedList theList = new LinkedList();
    LinkedListIterator theItr;/*from ww w . j  av  a 2 s  . com*/

    theItr = theList.zeroth();
    printList(theList);

    for (int i = 0; i < 10; i++) {
        theList.insert(new Integer(i), theItr);
        printList(theList);
        theItr.advance();
    }
    System.out.println("Size was: " + listSize(theList));

}

From source file:VectorBenchmark1.java

public static void main(String[] args) {
    Vector v = new Vector();

    long start = System.currentTimeMillis();
    for (int i = 0; i < MaxSize; i++)
        v.add(new Integer(i));
    long end = System.currentTimeMillis();
    System.out.println("Allocating vector elements: " + (end - start) + " milliseconds");

    Integer[] integerArray = new Integer[1];
    start = System.currentTimeMillis();
    for (int i = 0; i < MaxSize; i++) {
        if (i >= integerArray.length) {
            Integer[] b = new Integer[i * 2];
            System.arraycopy(integerArray, 0, b, 0, integerArray.length);
            integerArray = b;/* w w w  .  ja v  a 2 s .  c om*/
        }
        integerArray[i] = new Integer(i);
    }
    end = System.currentTimeMillis();
    System.out.println("Allocating array elements:  " + (end - start) + " milliseconds");

    start = System.currentTimeMillis();
    for (int j = 0; j < NTRIES; j++)
        for (int i = 0; i < MaxSize; i++) {
            Integer r = (Integer) v.get(i);
            v.set(i, new Integer(r.intValue() + 1));
        }
    end = System.currentTimeMillis();
    System.out.println("Accessing vector elements:  " + (end - start) + " milliseconds");

    start = System.currentTimeMillis();
    for (int j = 0; j < NTRIES; j++)
        for (int i = 0; i < MaxSize; i++) {
            Integer r = integerArray[i];
            integerArray[i] = new Integer(r.intValue() + 1);
        }
    end = System.currentTimeMillis();
    System.out.println("Accessing array elements:   " + (end - start) + " milliseconds");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int capacity = 10;
    BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);

    for (int i = 0; i < 10; i++) {
        queue.add(i);//from w ww.  j  a va  2s.c  o  m
    }

    System.out.println(queue.remove(new Integer(0)));
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Class cls = Class.forName("constructor2");
    Class partypes[] = new Class[2];
    partypes[0] = Integer.TYPE;/*from w  ww  . jav  a2s  .c  om*/
    partypes[1] = Integer.TYPE;
    Constructor ct = cls.getConstructor(partypes);
    Object arglist[] = new Object[2];
    arglist[0] = new Integer(37);
    arglist[1] = new Integer(47);
    Object retobj = ct.newInstance(arglist);

}

From source file:PrintWriterDemo.java

public static void main(String args[]) throws Exception {

    PrintWriter pw = new PrintWriter(System.out);

    // Experiment with some methods
    pw.println(true);/*  w  w  w . j  a  va2s.c  o  m*/
    pw.println('A');
    pw.println(500);
    pw.println(40000L);
    pw.println(45.67f);
    pw.println(45.67);
    pw.println("Hello");
    pw.println(new Integer("99"));

    // Close print writer
    pw.close();
}

From source file:BuilderMain.java

public static void main(String[] args) {
    InsertBuilder builder = new InsertBuilder();
    builder.setTable("employees");
    builder.addColumnAndData("employee_id", new Integer(221));
    builder.addColumnAndData("first_name", "'Shane'");
    builder.addColumnAndData("last_name", "'Grinnell'");
    builder.addColumnAndData("email", "'al@yahoo.com'");

    String sql = SQLDirector.buildSQL(builder);
    System.out.println(sql);/*from  w  w w  . j av a2  s .  c  om*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JSlider slider = new JSlider();

    Dictionary table = slider.getLabelTable();

    ImageIcon icon = new ImageIcon("icon.gif");
    JLabel label = new JLabel(icon);

    // Set at desired positions
    table.put(new Integer(slider.getMinimum()), label);
    table.put(new Integer(slider.getMaximum()), label);

    // Force the slider to use the new labels
    slider.setLabelTable(table);/*from  w  w  w .ja  v  a 2s  .  co m*/

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Object[][] data = { { "A", new Integer(3), new Double(7.23), new Boolean(true) },
            { "J", new Integer(2), new Double(4.64), new Boolean(false) },
            { "S", new Integer(1), new Double(8.81), new Boolean(true) } };

    String[] columns = { "Col", "Col", "Col", "Col" };

    JTable table = new JTable(data, columns);
    JScrollPane scroll = new JScrollPane(table);

    JFrame f = new JFrame();
    f.setContentPane(scroll);//from   w ww  .  j a  v a 2 s .  c  o m
    f.pack();

    int x = (int) table.getTableHeader().getSize().getWidth();
    int y = (int) table.getTableHeader().getSize().getHeight() + (int) table.getSize().getHeight();

    BufferedImage bi = new BufferedImage((int) x, (int) y, BufferedImage.TYPE_INT_RGB);

    Graphics g = bi.createGraphics();
    table.getTableHeader().paint(g);
    g.translate(0, table.getTableHeader().getHeight());
    table.paint(g);
    g.dispose();

    JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(bi)));
    ImageIO.write(bi, "png", new File("c:/Java_Dev/table.png"));

    System.exit(0);
}

From source file:jsonencodedemo.JsonEncodeDemo.java

public static void main(String[] args) {
    JSONObject obj = new JSONObject();

    obj.put("name", "Jordan");
    obj.put("school", "BYUI");
    obj.put("age", new Integer(31));
    obj.put("year", new Integer(2015));
    obj.put("is_student", new Boolean(true));

    System.out.print(obj);/*from   w  ww  . j a  v a2  s  . c om*/
}