The class to be called
package ss;public class Use { public static Integer demo( String s ){ System.err.println(s+"<<<<<<<<<<< Success!"); Integer ss=1; return ss; }} The class that executes the call
public class Ceshi { public static void main(String[] args) { try { String className = "ss.Use"; Class<?> testClass = Class.forName(className); Method sadMethod2 = testClass.getMethod("demo", new Class[]{String.class}); String result=saddMethod2.invoke(null,new Object[]{"test reflection"}).toString(); System.out.println(result); } catch (Exception e) { e.printStackTrace(); }}The above article JAVA reflection dynamically calls different types of static methods (recommended) is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.