-2

I was wondering if I can actually return a BigDecimal from a function as I have not seen anything online about this. Is it because it's not possible or is it really just bad practice to do so? Attempting the code below results in "error: cannot find symbol [in MainClass.java]"

public BigDecimal foo(){
    return new BigDecimal(10);
}
  • 4
    Maybe you are missing a `import java.math.BigDecimal` . – Arnaud Jan 30 '19 at 07:42
  • There are many possible reasons for this error and without seeing [mcve] we can't tell for sure what is wrong. Use [edit] option to improve your post. For now I marked it as duplicate of [What does a “Cannot find symbol” compilation error mean?](https://stackoverflow.com/q/25706216) which list of many reasons for that problem to appear. – Pshemo Jan 30 '19 at 07:53

1 Answers1

4

There's absolutely nothing wrong with returning a BigDecimal from a method. In fact, the JDK has several methods that do that. Chances are you're just missing import java.math.BigDecimal, or something to that effect.

Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94
Mureinik
  • 297,002
  • 52
  • 306
  • 350