MCPcopy Create free account
hub / github.com/castello/spring_basic / main

Method main

ch2/MethodInfo.java:8–32  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

6
7public class MethodInfo {
8 public static void main(String[] args) throws Exception{
9
10 Class clazz = Class.forName("com.fastcampus.ch2.YoilTeller");
11 Object obj = clazz.newInstance();
12
13 Method[] methodArr = clazz.getDeclaredMethods();
14
15 for(Method m : methodArr) {
16 String name = m.getName();
17 Parameter[] paramArr = m.getParameters();
18// Class[] paramTypeArr = m.getParameterTypes();
19 Class returnType = m.getReturnType();
20
21 StringJoiner paramList = new StringJoiner(", ", "(", ")");
22
23 for(Parameter param : paramArr) {
24 String paramName = param.getName();
25 Class paramType = param.getType();
26
27 paramList.add(paramType.getName() + " " + paramName);
28 }
29
30 System.out.printf("%s %s%s%n", returnType.getName(), name, paramList);
31 }
32 } // main
33}
34
35/* [실행결과]

Callers

nothing calls this directly

Calls 1

getNameMethod · 0.45

Tested by

no test coverage detected