import java.text.DecimalFormat;
import java.util.Random;
public class Test {
public static void main(String[] args) {
DecimalFormat dcmFmt = new DecimalFormat("0.00");
Random rand = new Random();
float f = rand.nextFloat() * 1000;
System.out.println(dcmFmt.format(f));
}
}
----------------
657.28
import java.text.DecimalFormat;
public class F {
public static void main(String arg[]){
float f=2342.24234f;
System.out.println(new DecimalFormat("#.00").format(f));
}
}