There are many built in methods we can use to conduct mathematical operations to numbers. Here are some of them.
class Class1{ public static void main(String args[]){ //How far number is from zero. System.out.println(Math.abs(-26.7)); //Rounds number up. System.out.println(Math.ceil(7.4)); //Rounds number down. System.out.println(Math.floor(7.8)); //Greater of the two numbers. System.out.println(Math.max(8.6, 5.2)); //Smaller of the two numbers. System.out.println(Math.min(8.6, 5.2)); //First number to the power of the second number. System.out.println(Math.pow(5, 3)); //Square root of the number. System.out.println(Math.sqrt(9)); } }
All pretty self explanatory.