Convert double to float in Java

Just cast your double to a float. [java]double d = getInfoValueNumeric(); float f = (float)d; [/java] Also notice that the primitive types can NOT store an infinite set of numbers: [java]float range: from 1.40129846432481707e-45 to 3.40282346638528860e+38 double range: from 1.7e–308 to 1.7e+308 [/java]

Is there a general string substitution function similar to sl4fj?

String.format [java]String str = String.format("Action %s occured on object %s.", objectA.getAction(), objectB); [/java] Or [java]String str = String.format("Action %s occured on object %s with outcome %s.", new Object[]{objectA.getAction(), objectB, outcome}); [/java] You can also use numeric positions, for example to switch the parameters around: [java]String str = String.format("Action %2$s occured on object %1$s.", objectA.getAction(), objectB); … Read more