Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java

Literals/Constants

Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

adplus-dvertising
Math Class Function and Constant
Previous Home Next

The math class package is used java.lang.math,The class Math contains methods for performing basic numeric operations such as the logarithm, square root, and trigonometric functions. The Math class in the java.lang package provides methods and constants for doing more advanced mathematical computation. The methods in the Math class are all static, so you call them directly from the math class name. Since it is in the java.lang package, the Math class need not be imported.

Math.E

Math consists two constants.

Math.E, which is the base of natural logarithms, and represents the value of e, the base of the natural logarithms, about 2.718282.

public static final double E = 2.718281828459045

Math.PI, which is the ratio of the circumference of a circle to its diameter. About 3.14159265

public static final double PI = 3.141592653589793;

Basic Math Methods:

Method Description
double abs(double d)
float abs(float f)
int abs(int i) Returns the absolute value of the argument
long abs(long lng)
double ceil(double d) Returns the smallest integer that is greater than or equal to the argument. Returned as a double.
double floor(double d)Returns the largest integer that is less than or equal to the argument. Returned as a double.
double rint(double d) Returns the integer that is closest in value to the argument. Returned as a double.
long round(double d)
int round(float f) Returns the closest long or int, as indicated by the method's return type, to the argument.
double min(double arg1, double arg2)
float min(float arg1, float arg2) Returns the smaller of the two arguments.
int min(int arg1, int arg2
long min(long arg1, long arg2)
double max(double arg1, double arg2)
float max(float arg1, float arg2
int max(int arg1, int arg2) Returns the larger of the two arguments.
long max(long arg1, long arg2)

Exponential and Logarithmic Methods:

Method Description
double exp(double d) Returns the base of the natural logarithms, e, to the power of the argument.
double log(double d) Returns the natural logarithm of the argument.
double pow(double base, double exponent) Returns the value of the first argument raised to the power of the second argument.
double sqrt(double d)returns the square root of the argument.

Trigonometric Methods:

Method Description
double sin(double d)Returns the sine of the specified double value.
double cos(double d) Returns the cosine of the specified double value.
double tan(double d)Returns the tangent of the specified double value.
double asin(double d)Returns the arcsine of the specified double value.
double acos(double d)Returns the arccosine of the specified double value.
double atan(double d) Returns the arctangent of the specified double value.
double atan2(double y, double x) Converts rectangular coordinates (x, y) to polar coordinate (r, theta) and returns theta.
double toDegrees(double d) Converts the argument to degrees or radians.
Previous Home Next