The Artima Developer Community
Sponsored Link

Java Buzz Forum
Find power using math.pow() in java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Find power using math.pow() in java Posted: Apr 23, 2017 10:46 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Find power using math.pow() in java
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
  • java.lang.Math.pow() method used to find the power of numbers.
  • It is a static method define in Math class so that we can call directly using classname.
  • Math.pow();
  • It takes two double arguments and return type is double.

  1. public final class Math extends Object
  1. public static double pow(double a, double b)



Java Program to explain the usage of Math.pow() method in java

  1. public class MathPow {
  2.  
  3.     /**
  4.      * Math.pow() method in java
  5.      * @author www.instanceofjava.com
  6.      */
  7. public static void main(String[] args) {
  8.     
  9.     
  10.     double a = 3.0;
  11.     double b = 4.0;
  12.  
  13.     
  14.     System.out.println("Math.pow(" + a + "," + b + ")=" + Math.pow(a, b));
  15.     System.out.println("Math.pow(" + b + "," + a + ")=" + Math.pow(b, a));
  16.    
  17.     System.out.println("Math.pow(4,2)="+Math.pow(4,2));
  18. }
  19.  
  20. }

Output:


  1. Math.pow(3.0,4.0)=81.0
  2. Math.pow(4.0,3.0)=64.0
  3. Math.pow(4,2)=16.0
math pow method in java

Read: Find power using math.pow() in java

Topic: Math.round() method in java Previous Topic   Next Topic Topic: Java example program to round double to 2 decimal places

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use