Why this works:
Object prova = 9.2;
System.out.println(prova);
Double prova2 = (Double) prova;
System.out.println(prova2);
And this doesn’t?
Object prova = 9.2;
System.out.println(prova);
Float prova2 = (Float) prova;
System.out.println(prova2);
I lost 1 hour in my java android application cause of this thing so i had to cast it in a double and than the double in a float or i had an exception
Because you are relying on autoboxing when you wrote
If you want it to be a Float, try
Remember that java.lang.Float and java.lang.Double are sibling types; the common type is java.lang.Number
If you want to express a Number in whatever format, use the APIs, for example Number.floatValue()