当前位置: 技术问答>java相关
编译一个很简单的程序出错,大家帮忙看看,多谢了。
来源: 互联网 发布时间:2015-02-10
本文导语: 我用的是JCreator 程序清单如下: /*methodpointertest.java*/ import java.lang.reflect.*; import corejava.*; public class methodpointertest { public static void main(String[] args)throws Exception { printTable(1,10,10, mothodpointertest.class.getMethod("square",...
我用的是JCreator
程序清单如下:
/*methodpointertest.java*/
import java.lang.reflect.*;
import corejava.*;
public class methodpointertest
{
public static void main(String[] args)throws Exception
{
printTable(1,10,10,
mothodpointertest.class.getMethod("square",
new Class[] {double.class}));
printTable(1,10,10,java.lang.Math.class.getMethod("sqrt",
new Class[] {double.class}));
}
public static double square(double x){return x*x;}
public static void printTable(double from,double to,int n,Method f)
{
System.out.println(f);
double dx=(to-from)/(n-1);
for(double x=from;x
程序清单如下:
/*methodpointertest.java*/
import java.lang.reflect.*;
import corejava.*;
public class methodpointertest
{
public static void main(String[] args)throws Exception
{
printTable(1,10,10,
mothodpointertest.class.getMethod("square",
new Class[] {double.class}));
printTable(1,10,10,java.lang.Math.class.getMethod("sqrt",
new Class[] {double.class}));
}
public static double square(double x){return x*x;}
public static void printTable(double from,double to,int n,Method f)
{
System.out.println(f);
double dx=(to-from)/(n-1);
for(double x=from;x