Doesn't Java provide it? I can't find, it looks like I can pass only objects, but static methods do not belong any objects besides scope. Do you think passing Method which can be invoked a good solution? Or maybe just pass instance of Class object or its name and get Method in a called method? Any thoughts?
One can pass methods (static or instance) around via the Method class from the Reflection API. However, if you are indeed a beginner, then this is fairly tricky stuff. It is quite likely that there is a simpler, more object-oriented way of achieving your real goal. Please tell us more.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Sounds to me like you should take a look at the Strategy design pattern.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by marc weber: What exactly are you trying to accomplish?
(It sounds like you might be looking for a design pattern of some sort, but I can't tell.)
Let's say I have a bunch of Java applications which provides a static method cancel(). So when I launch such application I want to pass it in some control module which will be able to cancel its execution. I could wrap cancel method in an object and pass a reference to this object (I think Ilia named it Strategy) however I'd like to pass static method reference directly.
Well, as has been said, you could use java.lang.reflect.Method objects; for that matter, you could pass the class name and use reflection to find and call the methods. But why are things designed this way in the first place, using static methods? Why not just do it the easy and right way and use a "Cancelable" interface with a cancel() method?