CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    3

    Alternative to Function Pointers in Java

    We are working on a repository based system. We have stored function names in a database table.
    These functions are nothing but class files.
    Depending upon user selection, function name will be retrieved from the table. We need to execute this function (service),
    but we are getting just a String which contains the function name. In C++ we can make use of Function pointers for the same.
    Is there any means to do it in Java?

    Thanks.


  2. #2
    Join Date
    May 1999
    Posts
    93

    Re: Alternative to Function Pointers in Java

    For this particular type of scenario, you can do one better than C++. In C++, within the code, you have to create a map between the function name string and the function (pointer). In Java, you can use the Reflection API. Given it is not as straight forward but you could write a utility routine to do it.

    You can learn more about the Reflection API from the Java docs. Also, read Bruce's book (online at this site) - Thinking in Java


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured