List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:Main.java
public static void main(String[] args) { // get a number as integer Number x = new Integer(123456); // get a number as float Number y = new Float(9876f); // print their value as double System.out.println("x as integer :" + x + ", x as double:" + x.doubleValue()); System.out.println("y as float::" + y + ", y as double:" + x.doubleValue()); }
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[] argv) throws Exception { JFormattedTextField tft2 = new JFormattedTextField(new DecimalFormat("#.0")); tft2.setValue(new Float(123.4F)); // Retrieve the value from the text field Float floatValue = (Float) tft2.getValue(); }
From source file:Test.java
public static void main(String[] args) { ArrayList<Integer> a1 = new ArrayList<>(); a1.add(new Integer(1)); a1.add(2);//from w w w.ja va 2 s . c o m ArrayList<Float> a2 = new ArrayList<>(); a2.add(new Float(3.0)); a2.add(new Float(4.0)); displayElements(a1, a2, 12); }
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)); vector.addElement(new String("Hello")); Enumeration e = vector.elements(); while (e.hasMoreElements()) { Object obj = e.nextElement(); System.out.println(obj);/*from w w w .jav a2 s .co m*/ } }
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 ww w .j a v a 2s. c o 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[] args) { float f1 = 5.5f; float f2 = 5.4f; int i1 = Float.compare(f1, f2); if (i1 > 0) { System.out.println(">"); } else if (i1 < 0) { System.out.println("<"); } else {// w ww . j a v a2s . c om System.out.println("="); } Float fObj1 = new Float("5.5"); Float fObj2 = new Float("5.4"); int i2 = fObj1.compareTo(fObj2); if (i2 > 0) { System.out.println(">"); } else if (i2 < 0) { System.out.println("<"); } else { System.out.println("="); } }
From source file:PlanetDiameters.java
public static void main(String args[]) { String names[] = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" }; float diameters[] = { 4800f, 12103.6f, 12756.3f, 6794f, 142984f, 120536f, 51118f, 49532f, 2274f }; Hashtable hash = new Hashtable(); for (int i = 0, n = names.length; i < n; i++) { hash.put(names[i], new Float(diameters[i])); }// w w w . j a va2s . c o m Enumeration e = hash.keys(); Object obj; while (e.hasMoreElements()) { obj = e.nextElement(); System.out.println(obj + ": " + hash.get(obj)); } }
From source file:DiameterMap.java
public static void main(String args[]) { String names[] = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" }; float diameters[] = { 4800f, 12103.6f, 12756.3f, 6794f, 142984f, 120536f, 51118f, 49532f, 2274f }; Map map = new TreeMap(); for (int i = 0, n = names.length; i < n; i++) { map.put(names[i], new Float(diameters[i])); }/* ww w .j ava2 s. co m*/ Iterator it = map.keySet().iterator(); Object obj; while (it.hasNext()) { obj = it.next(); System.out.println(obj + ": " + map.get(obj)); } }
From source file:SVGDOC2JPEG.java
public static void main(String[] args) throws Exception { JPEGTranscoder transcoder = new JPEGTranscoder(); transcoder.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME, "org.apache.crimson.parser.XMLReaderImpl"); transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0)); TranscoderInput input = new TranscoderInput(new FileInputStream("rectangles.svg")); OutputStream ostream = new FileOutputStream("out.jpg"); TranscoderOutput output = new TranscoderOutput(ostream); transcoder.transcode(input, output); ostream.close();//from ww w . ja va 2 s . com System.exit(0); }