This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to add main method to this, to check if it works. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to add main method to this, to check if it works." Watch "How to add main method to this, to check if it works." New topic
Author

How to add main method to this, to check if it works.

Laura Rubyte
Greenhorn

Joined: Feb 25, 2012
Posts: 1
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
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 530
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
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32708
    
    4
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to add main method to this, to check if it works.
 
Similar Threads
TreeNode ClassCastException?
Tree with parents
creating a new JPanel from another JPanel "choice" button
Exception Constructor Error
ID:11 SCJP Question of the Day !!!