Created
December 21, 2015 14:21
-
-
Save cobratbq/00fec1cea8c710d1930b to your computer and use it in GitHub Desktop.
Example 1: Util without state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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