File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling methods

 
Elon Zibitt
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, so i have a class that has 2 methods. method 1 parses an xml document and grabs a specific value. the second method formats the value. do i have to run both methods from a thrid method in order for the main to print out the formatted value? if so how would i do that?
 
timothy zimmerman
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could call both methods from within the main method.
public static void main(Sting[] args)
{
// this example is assuming the value is a String
// of course it may be whatever
String value = method1( xmldocument);
String foirmattedValue = method2( value );
// or you could do it this way but it is a little less obvious
// chaine the output of method1 into the call to method 2
String formattedValue = method2( method1(xmldocument) );
}
 
Peter Tran
Bartender
Posts: 783
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
timonthy's solution assumes that everything inside the class containing this main method is static. If they aren't and method1 and method2 are instance methods, then you'll need to allocate an instance of the class before you call those methods.

-Peter
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic