Wednesday 11 September 2013

Dynamically formatting a string in java

Dynamically formatting a string in java

Is there a way to dynamically format a float value?
I thought i could do something like this:
System.out.println(new BigDecimal(String.format("%" + k + "s",
answer)).toPlainString());
Where k is the increments each time through a loop... however, this
doesn't seem to do the trick...
any ideas?

No comments:

Post a Comment