遇到与处理方法有关的问题。这是一个简单的程序,但我似乎无法让我的数据打印到终端无法在使用方法时在我的终端中显示我的输出
这里是我的代码:
public class method
{
public static void main(String args[])
{
double result = 0;
int i;
System.out.println("i" + "\t\t" + "m(i)");
System.out.println("-------------------");
//columns and header
}
public double theSum(int i, double result)
{
for(i=0; i < 21; i++)
{
System.out.print(i + "\t\t" + result + "\n");
result +=(double) (i + 1)/(i+2);
// computing the data
}
return result;
}
}
一切编译,但我只输出打印邮件标题中...我认为我的底部方法可能是错误的,但不知道在哪里。
Sample output:
1 0.5
2 1.16
...
19 16.40
20 17.35
你打电话给你的方法吗?或者你期望它会自称? Java只会做你告诉它做的事情。 –