Java-为什么不';t方法显示?
我不知道为什么这不是在苹果中展示水果。Java-为什么不';t方法显示?,java,Java,我不知道为什么这不是在苹果中展示水果。 我有另一部分代码要显示showSum,效果很好。所以我不知道为什么它不会展示水果。我想将它转换为双精度的整数您正在将一个值设置为apples。 我想你会混淆苹果是一个变量,也是一个方法。最好将该方法重命名为更通用的方法,如printFruit,然后调用该方法。请参阅下面的代码: import java.io.*; public class test { public static void main(String[] args)throws IOE
我有另一部分代码要显示
showSum
,效果很好。所以我不知道为什么它不会展示水果。我想将它转换为双精度的整数您正在将一个值设置为apples
。
我想你会混淆苹果是一个变量,也是一个方法。最好将该方法重命名为更通用的方法,如printFruit
,然后调用该方法。请参阅下面的代码:
import java.io.*;
public class test
{
public static void main(String[] args)throws IOException
{
double apples = 1.7;
//showSum(5, 10);
}
public static void apples(double fruit)
{
System.out.println("number of fruit: " + fruit);
}
}
您需要调用与调用showSum相同的apples方法,即is apples(1.7)。 “double apple=1.7;”正在创建一个名为apple的变量,并将其赋值为1.7代码>?
import java.io.*;
public class test
{
public static void main(String[] args)throws IOException
{
double apples = 1.7;
printFruit(apples);
//showSum(5, 10);
}
public static void printFruit(double fruit)
{
System.out.println("number of fruit: " + fruit);
}
}