Find power using Math.pow - Java Language Basics

Java examples for Language Basics:Math

Description

Find power using Math.pow

Demo Code

 
public class Main {
 
  public static void main(String[] args) {
     //returns 2 raised to 2, i.e. 4
     System.out.println(Math.pow(2,2));
   /*from ww w. j  a  v  a 2s  .c om*/
     //returns -3 raised to 2, i.e. 9
     System.out.println(Math.pow(-3,2));
  }
}

Result


Related Tutorials