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
Joined: Jun 26, 2001
Posts: 149
posted
0
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
Joined: Jan 02, 2001
Posts: 783
posted
0
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.