About 56,100 results
Open links in new tab
  1. Should I import a math library, and if so how? - Stack Overflow

    Feb 23, 2014 · Since Math is in the java.lang package, it does not need to be imported. java.lang is the "default package" and everything in it is already implicitly imported for you.

  2. How do I properly use the java.lang.Math? - Stack Overflow

    Everything in java.lang is automatically imported. If you want something from Math, you would say Math.sin (x) (for example) (you can also use a "static import").

  3. java - Importing Math.PI as reference or value - Stack Overflow

    The statements import java.lang.Math; and import java.lang.Math.*; will not enable the code to compile and run. These import statements will only allow Math.PI as a reference to the PI …

  4. Getting random numbers in Java - Stack Overflow

    I would like to get a random value between 1 to 50 in Java. How may I do that with the help of Math.random();? How do I bound the values that Math.random() returns?

  5. Why can't my program access the math methods in Java?

    May 22, 2013 · If you're actually trying to use the standard Java Math package, you need to either get rid of anything named Math.java in your project directory, since that will conflict with the …

  6. java.lang.Math.abs not imported by default? - Stack Overflow

    Feb 11, 2015 · Math.abs() to directly (without any import statement) call the abs() method. But this only works for the static method in java.lang package, since they are imported by default.

  7. android - I can't use math methods in Java - Stack Overflow

    Aug 4, 2012 · Use a static import for each function you want: import static java.lang.Math.hypot; // etc Use a wildcard static import: import static java.lang.Math.*; Explicitly refer to the static …

  8. Why is RoundingMode is not resolving in Java 21? [closed]

    Mar 5, 2024 · The class that I am trying to use is import java.math.RoundingMode; // <--this doesn't resolve Error: "Cannot resolve symbol 'RoundingMode'" This is the method that I'm …

  9. What is the difference between import static java.lang.Math.* and ...

    Jul 24, 2020 · The code block in your question says import java.lang.Math;, which would be unnecessary and does not seem to be what the rest of your question is asking about.

  10. Is there a method that calculates a factorial in Java?

    May 21, 2009 · In fact, the value of 20! is the largest one can represent in a Java long. So the following method will either calculate factorial (n) or throw an IllegalArgumentException if n is …