java class类

引用

private String getMessage_field(Object o){
 


Class c=o.getClass();
Method[] methods=c.getDeclaredMethods();

    String ss="";
      
        for(int i=0;i<methods.length;i++){
       
            if(methods[i].getName().startsWith("get")){
            System.out.println(methods[i].getName());
                Method method=methods[i];
              
                    try {
                   
                        ss+=method.invoke(o)+"|";
                    } catch (Exception e) {
                       
                        System.out.println("注入值时出错"+e);
                    }
}

        }
      
       
      return ss;
}

你可能感兴趣的:(java,C++,c,C#)