Google is your friend in this case as there is a plethora of examples, anyway this is just a small example in java of how printf can be used
public static void main(String args)
double x = 1;
double y = 3;
double z = x / y; //would be 0.333->till memory for double is used up
//printf using 2 decimal place modifier.
This would print 0.33 so it can be used to manipulate what the user views etc... hope it helps a bit