Skip to content

Instantly share code, notes, and snippets.

@cobratbq
Created December 21, 2015 14:21
Show Gist options
  • Save cobratbq/00fec1cea8c710d1930b to your computer and use it in GitHub Desktop.
Save cobratbq/00fec1cea8c710d1930b to your computer and use it in GitHub Desktop.
Example 1: Util without state
package thirdcomponent;
import java.math.BigDecimal;
import java.math.MathContext;
public class UtilNoState {
public static void main(String[] args) {
System.out.println(calculate(BigDecimal.ONE,
BigDecimal.valueOf(3L), MathContext.DECIMAL32));
// prints 0.3333333
}
public static BigDecimal calculate(BigDecimal x,
BigDecimal y, MathContext c) {
return x.divide(y, c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment