Example usage for java.lang Double Double

List of usage examples for java.lang Double Double

Introduction

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

Prototype

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

Source Link

Document

Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string.

Usage

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);//from   w w w . ja  v a2s  . c  o m
}

From source file:MessageFormatReuse.java

public static void main(String args[]) {
    String pattern = "{0}K was deleted on {1}.";
    MessageFormat formatter = new MessageFormat(pattern);

    Double kb = new Double(3.5);
    Date today = new Date();
    Object[] arguments = { kb, today };

    formatter.setLocale(Locale.US);
    System.out.println(formatter.format(arguments));
}

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   w  w  w. j  ava 2  s  . co m*/
}

From source file:MainClass.java

public static void main(String[] argv) {
    String pattern = "{0}K was deleted on {1}.";
    MessageFormat formatter = new MessageFormat(pattern);

    Double kb = new Double(3.5);
    Date today = new Date();
    Object[] arguments = { kb, today };

    formatter.setLocale(Locale.US);
    System.out.println(formatter.format(arguments));

    formatter.setLocale(Locale.FRANCE);
    System.out.println(formatter.format(arguments));

    pattern = "On {1}, {0}K was deleted.";
    formatter.applyPattern(pattern);/*from w w  w  .java 2s. co  m*/
    System.out.println(formatter.format(arguments));

    formatter.setLocale(Locale.US);
    System.out.println(formatter.format(arguments));
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Hashtable h = new Hashtable();
    h.put("string", "AAA");
    h.put("int", new Integer(26));
    h.put("double", new Double(Math.PI));

    FileOutputStream fileOut = new FileOutputStream("hashtable.ser");
    ObjectOutputStream out = new ObjectOutputStream(fileOut);
    out.writeObject(h);/* ww  w.j a  v a2s. c  om*/

    FileInputStream fileIn = new FileInputStream("h.ser");
    ObjectInputStream in = new ObjectInputStream(fileIn);
    Hashtable h = (Hashtable) in.readObject();
    System.out.println(h.toString());
}

From source file:Gen.java

public static void main(String args[]) {
    Gen<Integer> iOb = new Gen<Integer>(88);

    Gen<String> strOb = new Gen<String>("Generics Test");

    Gen raw = new Gen(new Double(98.6));

    double d = (Double) raw.getob();
    System.out.println("value: " + d);

    strOb = raw; // OK, but potentially wrong
    raw = iOb; // OK, but potentially wrong
}

From source file:MainClass.java

public static void main(String args[]) {

    HashMap<String, Double> hm = new HashMap<String, Double>();

    hm.put("A", new Double(3434.34));
    hm.put("B", new Double(123.22));
    hm.put("C", new Double(1378.00));
    hm.put("D", new Double(99.22));
    hm.put("E", new Double(-19.08));

    Set<Map.Entry<String, Double>> set = hm.entrySet();

    for (Map.Entry<String, Double> me : set) {
        System.out.print(me.getKey() + ": ");
        System.out.println(me.getValue());
    }//from   w  ww . jav a  2 s . co m

    System.out.println();

    double balance = hm.get("B");
    hm.put("B", balance + 1000);

    System.out.println("B's new balance: " + hm.get("B"));
}

From source file:MainClass.java

public static void main(String args[]) {

    TreeMap<String, Double> tm = new TreeMap<String, Double>();

    tm.put("A", new Double(3434.34));
    tm.put("B", new Double(123.22));
    tm.put("C", new Double(1378.00));
    tm.put("D", new Double(99.22));
    tm.put("E", new Double(-19.08));

    Set<Map.Entry<String, Double>> set = tm.entrySet();

    for (Map.Entry<String, Double> me : set) {
        System.out.print(me.getKey() + ": ");
        System.out.println(me.getValue());
    }/* ww w . j a  va2  s . c  o m*/
    System.out.println();

    double balance = tm.get("B");
    tm.put("B", balance + 1000);

    System.out.println("B's new balance: " + tm.get("B"));
}

From source file:Main.java

public static void main(String[] args) {
    double d1 = 5.5;
    double d2 = 5.4;
    int i1 = Double.compare(d1, d2);
    if (i1 > 0) {
        System.out.println(">");
    } else if (i1 < 0) {
        System.out.println("<");
    } else {//from www  .  ja  v a2 s  .  com
        System.out.println("=");
    }
    Double dObj1 = new Double("5.5");
    Double dObj2 = new Double("5.4");
    int i2 = dObj1.compareTo(dObj2);
    if (i2 > 0) {
        System.out.println(">");
    } else if (i2 < 0) {
        System.out.println("<");
    } else {
        System.out.println("=");
    }
}

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);//w  ww .  j av  a  2 s.c  om
    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);
}