Program to find the number of methods in a java program

I used the following code to identify the number of functions in a class. Similar way can any one help me to identify the number of functions in a java program. In my program i gave input file as a class. Guide me with the code to give input as a java program and to find the number of declared functions in it. import java.lang.reflect.*; import java.io.*; import java.lang.String.*; public class Method1 { private int f1( Object p, int x) throws NullPointerException { if (p == null) throw new NullPointerException(); return x; } public static void main(String args[])throws Exception { int Mcount=0,MthdLen=0; try { Class cls = Class.forName("Madhu"); int a; Method methlist[]= cls.getDeclaredMethods(); for (int i = 0; i < methlist.length;i++) { Method m = methlist[i]; Mcount = Mcount + 1; MthdLen=MthdLen+(m.getName().length()); } } catch (Throwable e) { System.err.println(e); } System.out.println("Length = " + MthdLen); System.out.println("Mcount = " + Mcount); } }
Would this happen to be homework?

以上就是Program to find the number of methods in a java program的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏