易截截图软件、单文件、免安装、纯绿色、仅160KB

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);
}
}
 


相关文档:

java冒泡排序!

int temp;
int [] arr=new int[];
for(int i=0;i<arr.length;i++)
{
    for(int j=0;j<arr.length-i-1;j++)
    {
         if(arr[j]<arr[j+1])
          {
   & ......

java中如何把一个目录下的文件移到另一个指定目录中

 import java.io.*;
public class FileToFile
{
 public static void main(String[] args)
 {
   File fold = new File("e:\\java\\file.java");//某路径下的文件
   String strNewPath = "e:\\java\\new file\\";//新路径
   File fnewpath = new File(strNewPath); ......

java循环遍历map

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();
......

java递归实例

 example: 求5的阶乘。。

如下:

public class Test {
static int multiply(int n){
if(n==1||n==0)
return n;
else
return n*multiply(n-1);
}

public static void main(String[] args){
System.out.println(multiply(10));
}
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号