Newton
class, you need to put the
contents of the Newton
class in a file. If
you are using Netscape, you can do this by holding down
Shift
and clicking the left mouse button
on:Newton.java.
From the UNIX command line, go to the directory you just
saved Newton.java in. Then type
javac Newton.java
. This will create
a java byte-code file called Newton.class
.
Now run the code with a guess of 2 by typing
java Newton 2
. You should see:
(maxwell@gamba.109) java Newton 2 Step: 1 x:4.18504 Value:-0.864144 Step: 2 x:2.46789 Value:0.623881 Step: 3 x:3.26619 Value:-0.124272 Step: 4 x:3.14094 Value:0.000648741 Step: 5 x:3.14159 Value:-9.10111e-11 Zero found at x=3.14159 (maxwell@gamba.110)
![]() |
5.4 The Basic Structure of Java Code |