In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
In this article Xiaobian introduces in detail "how to use the Math class in Java programming", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to use the Math class in Java programming" can help you solve your doubts.
1. Mathclass
1. The class contains basic mathematical operation methods, such as addition, subtraction, multiplication, division, remainder, etc., they can not carry out complex operations, in the Math class to find the absolute value, square root, trigonometric function, etc., all classes in the Math class are static and can be called with its class name.
two。 Static constant
The Math class contains two static constants, PI and E, which represent mathematical pi (pi) and e (natural logarithm), respectively.
3. Static constant example
Public class p61 {public static void main (String [] args) {/ / TODO Auto-generated method stub System.out.println ("PI its constant value:" + Math.PI); System.out.println ("E its constant value:" + Math.E);}}
The result of the operation is:
2. Absolute value of Mathth class
1. The characteristic of an absolute value is a positive number, the absolute value of zero is itself, and the absolute value of a negative number is its opposite.
Method for the absolute value of the 2.Math class:
Public static int abs (int a) method: returns the absolute value of the int type value
Public static float abs (float a) method: returns the absolute value of the float type value
Public static double abs (double a) method: returns the absolute value of the double type value
Public static long abs (long a) method: returns the absolute value of the long type value
Example of the absolute value method of the 3.Math class:
Import java.util.Scanner; public class p67 {public static void main (String [] args) {/ / TODO Auto-generated method stub System.out.println ("Please enter an integer"); Scanner scan=new Scanner (System.in); int a=scan.nextInt (); if (a > 0) {System.out.println ("positive absolute value is itself") System.out.println (Math.abs (a));} else if (a)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.