Skip to content
Advertisement

Tag: exists

How To Check If A Method Exists At Runtime In Java?

How would one go about checking to see if a method exists for a class in Java? Would a try {…} catch {…} statement be good practice? Answer I assume that you want to check the method doSomething(String, Object). You might try this: This will not work, since the method will be resolved at compile-time. You really need to use

Advertisement