Java Float Number Create toFloat(Object obj)

Here you can find the source of toFloat(Object obj)

Description

to Float

License

Open Source License

Declaration

static Float toFloat(Object obj) 

Method Source Code

//package com.java2s;

public class Main {
    static Float toFloat(Object obj) {
        if (obj instanceof String)
            return Float.valueOf((String) obj);
        if (obj instanceof Byte) {
            Byte b = (Byte) obj;
            return b.floatValue();
        }/*from   w ww  .j  av a  2 s.co m*/
        if (obj instanceof Short) {
            Short s = (Short) obj;
            return s.floatValue();
        }
        if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            return i.floatValue();
        }
        if (obj instanceof Long) {
            Long l = (Long) obj;
            return l.floatValue();
        }
        return (Float) obj;
    }
}

Related

  1. toFloat(Object literal)
  2. toFloat(Object o)
  3. toFloat(Object o)
  4. toFloat(Object o)
  5. toFloat(Object ob, Float defaultFloat)
  6. toFloat(Object obj)
  7. toFloat(Object obj)
  8. toFloat(Object obj)
  9. toFloat(Object obj, String pattern)