How to add main method to this, to check if it works.
Joined: Feb 25, 2012
Hi , I have this code :
And I need to test programm by addinf a main method and the calling getRoot method with a parameter to set result.
I know that i have to create a main method that would call the written function, but have no idea how to do it. Any help appreciated.thanks
Joined: Oct 24, 2010
As you said, there are at least 2 approaches: you can add a main() method to the existing class file, or you can create another class file whose sole function is to test the class file you posted. In either case, the main() method would look something like:
How you get aNumber or the other things you might do with the test instance to test it thoroughly are up to you.
Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Joined: Oct 13, 2005
Welcome to the Ranch
Once you have the root approximation object Greg showed you, you can call its gteRoot() method and use the result however you wish.