Help me please Math squirt stopped working

Hi,

I hope some one can help.

I got a java 2 beginners book that I've been learning out of. The thing is I got away from it for a while so when I came back I kinda started going back through the book

at the begining. Here's the exact code with the problem,

I wrote this some time ago directly out of the book, and it worked fine, but now when I tried to write it again it won't compile:

class Hypot {

public static void main(String args[]) {

double x, y, z;

x = 3;

y = 4;

z = Math.sqrt(x*x + y*y);

System.out.println("The Hypotenuse is " +z);

}

}

Heres the error I get when I try to compile, mind you this worked a couple of months ago with no probs.

Im thinking maybe somthing is conflicting with it?

****

Math.java:8: cannot resolve symbol

symbol : method sqrt (double)

location: class Math

c = Math.sqrt(x*x + y*y);

^

1 error

sorry to be so long winded.

Thanks in advance to anyone who can give some advice.

Dave 102979dd@gte.net

[1108 byte] By [blizeach] at [2007-9-26 3:11:27]
# 1
It worked for me.Did you try to do "import java.lang.*;" at the beginning of the file?
aaronjanet at 2007-6-29 11:18:56 > top of Java-index,Archived Forums,Java Programming...
# 2
What version of java are you using?
jschell at 2007-6-29 11:18:56 > top of Java-index,Archived Forums,Java Programming...
# 3
1.3.1
aaronjanet at 2007-6-29 11:18:56 > top of Java-index,Archived Forums,Java Programming...
# 4

My thoughts:

1 - make sure you don't have a file called "Math.class" in the same directory as your program. If you do, the compiler will find it and use it instead of java.lang.Math.

2 - at the DOS prompt (or whatever prompt you have), type "set" and make sure that there is no variable called CLASSPATH. If there is, this may keep the compiler from finding packages (like java.lang). Figure out where the CLASSPATH is coming from (in Windows it's probably set in autoexec.bat) and get rid of it. Reboot and try again.

-J

jcolan at 2007-6-29 11:18:56 > top of Java-index,Archived Forums,Java Programming...
# 5
Maybe you should replace the c with z, since there's no c declared.
Kayaman at 2007-6-29 11:18:56 > top of Java-index,Archived Forums,Java Programming...