This post originated from an RSS feed registered with Java Buzz
by Arpit Mandliya.
Original Post: Power function in java
Feed Title: Java tutorial for beginners
Feed URL: http://feeds.feedburner.com/arpitmandliyasblog
Feed Description: A blog about java programming language and its frameworks
Power function in java is used to get first argument’s power to 2nd argument. For example: Let’s say you want to calculate 2 to the power 4. That will be 2*2*2*2=16 In java, you can do it by : Math.pow(2,4) =16 Syntax Example : Let’s use power function in java. When you run above program, you will get below output: Math.pow(2 ,4)=16.0 Math.pow(4.2,3)=74.08800000000001 If you want to return integer from power function, you need to explicitly cast it to Integer. When you run above program, you will get below output: Math.pow(2 ,4)=16 Internal working Math.pow is native