[Solved] the keyword “final” for BigDecimal.java [closed]

[ad_1] Immutable means, that class does not contain any method that would change it’s internal state. Example of immutable class: class ImmutableInteger { private final int value; public ImmutableInteger(int value) {this.value = value;} public int value() {return value;} public ImmutableInteger add(int a) { // instead of changing this state, we will create new instance with … Read more

[Solved] Why does my sorting method for Bigdecimal numbers fails to sort?

[ad_1] Well, since you want to use String numbers, you will have to wrap them in quotations, but your sorting can be much more readable. I would suggest the following String[] numbers ={“-100”, “50”, “0”, “56.6”, “90”, “0.12”, “.12”, “02.34”, “000.000”}; List<BigDecimal> decimalList = new ArrayList<>(); for(String s: numbers){ decimalList.add(new BigDecimal(s)); } Collections.sort(decimalList); Collections.reverse(decimalList); // … Read more