Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 5th, 2007, 01:05 PM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help with Math.pow

Hello, I'm learning Java from a book, and having some trouble compiling with Math.pow. According to the book, this little program should print the value of 5 raised to the fourth power:

public class Math5
{
    public static void main(String[] args)
    {
        System.out.println(Math.pow(5.0,4.0));

    }
}

But when I compile it, I receive an error message "cannot find symbol
symbol : method pow (double,double)." The location is marked as the dot between Math and pow.

Can anybody tell me what I'm doing wrong?
 
Old July 5th, 2007, 02:25 PM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Turns out the code was fine. I had saved another file as Math.java, which it turns out causes havoc, because Java starts looking to that file for all math operations. Deleting the file fixed it.
 
Old July 18th, 2007, 04:57 AM
Registered User
 
Join Date: Jul 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need to have a variable name so as to initialise it;for instance,

int number = 5;
int constant = 4;
double raise = 0;

raise = Math.pow(number,constant);
when you run this u should have 625 as your ans.

 
Old July 26th, 2007, 04:50 AM
Authorized User
 
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it will run and print the result

625.0

http://studyjava.org/forums/
 
Old July 27th, 2007, 06:12 AM
Registered User
 
Join Date: Jul 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey, I got the answer for it






Similar Threads
Thread Thread Starter Forum Replies Last Post
Math question dparsons ASP.NET 1.0 and 1.1 Professional 5 June 14th, 2006 02:31 PM
Math Namespace transtar C# 3 February 12th, 2006 09:50 AM
Math functions-Please help! jroxit ASP.NET 2.0 Basics 5 December 28th, 2005 12:21 PM
York Math -- regarding... vijayk Wrox Book Feedback 0 February 5th, 2005 06:23 AM
math.floor casper BOOK: Beginning Java 2 1 October 29th, 2004 11:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.