java 循环打印出某对象所在类的类名和方法
java 循环打印出某对象所在类的类名和方法
public class A {
public void b(){}
public void c(){}
public void d(){}
public void e(){}
}
import java.lang.reflect.*;
public class StaticTest {
public static void test(Object obj)
{
Class myclass = obj.getClass();
//System.out.println(myclass.getName());
Method[] mymethods = myclass.getDeclaredMethods();
int n = mymethods.length;
for(int i=0; i<n; i++)
{
System.out.println("类名:"+myclass.getName()+"; 方法名:"+mymethods[i].getName());
}
}
public static void main(String args[]){
A a = new A();
test(a);
}
}
相关文档:
/************Student.java begin***************/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Student {
private String name;
private String password;
public String getName() {
return name;
}
public ......
个人简历
个人信息
姓名
:
朱金国
性别
:
男
出生日期
:
1988
年
1
月
9
日
Email
:
zhujinguo2009@gmail.com
  ......
/**
* @(#)MyTray.java
*
*
* @author Xie Xiaojin
* @version 1.00 2009/11/9
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyTray implements ActionListener {
private MenuItem item1;
private MenuItem item2;
private MenuItem item3;
private ......
JDK1.4中
Map map = new HashMap();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
}
JDK1.5中,应用新特性For-Each循环
Map m = new HashMap();
......
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BubbleSort {
private static int a[] = new int[12];
private static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static void bubbleSort(int a[], i ......