aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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 Ruby
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: 563
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.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
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://aspose.com/file-tools
 
subject: How to add main method to this, to check if it works.