Brad Cadle
January 23rd, 1999, 06:24 PM
Hi All,
I am a Java Beginner. I am trying to code up some numerical routines which expect to call some user supplied subroutines. What is the most appropriate way to do this in java. In fortan or C one would could declare an external function which the user would provide. Also in C one supply this by passing a pointer to a function. In C++ one could declare a virtual function of a class and derive a new class from it.
I am having a single class that will contain all the numerical methods, but some of the methods will be calling user supplied funtions.
1) One way could be to have the user create an object of some second class that is passed to the numerical method class which then owns it. The numerical methods class could then call the function supplied into the second class passed to it.
Are there alternate ways in Java to handle having my class call the third party supplied functions? What are they?
-Brad
I am a Java Beginner. I am trying to code up some numerical routines which expect to call some user supplied subroutines. What is the most appropriate way to do this in java. In fortan or C one would could declare an external function which the user would provide. Also in C one supply this by passing a pointer to a function. In C++ one could declare a virtual function of a class and derive a new class from it.
I am having a single class that will contain all the numerical methods, but some of the methods will be calling user supplied funtions.
1) One way could be to have the user create an object of some second class that is passed to the numerical method class which then owns it. The numerical methods class could then call the function supplied into the second class passed to it.
Are there alternate ways in Java to handle having my class call the third party supplied functions? What are they?
-Brad