【发布时间】:2014-09-28 18:51:41
【问题描述】:
我有非常简单的代码,我已经删除了奇数代码。
所以这是我的课,他的方法之一是静态的,我想稍后在Main class 中使用它:
public class TradeInformationReader {
private static String tradeType = "FX_SPOT";
public static double tradePrice = -1;
private double price;
public static int setTradeInformation(String path_to_file) {
return 1;
}
}
这里是我如何尝试调用最后一个方法:
public class Main {
public static int main(String[] args) {
String path_to_file = "D:\\1.txt";
if (0 > TradeInformationReader.setTradeInformation(path_to_file)) {
return -1;
}
return 1;
}
}
我阅读了许多类似问题的帖子,但找不到解决方案。在我看来一切都很好。 IDE 没有显示任何错误,我只是尝试调用静态方法setTradeInformation,为什么它无法识别它(找不到符号方法setTradeInformation)?有任何想法吗?非常感谢您的帮助。
【问题讨论】:
-
无法识别的符号是什么?
-
为什么setTradeInformation总是返回1?
-
@Kick Buttowski 我认为这只是一个例子......他知道如果实现真的是那样,它永远不会进入第二个 IF 条件。
-
TradeInformationReader是内部类吗? (未在其自己的文件中定义) -
@NicolasAlbert 我调用静态方法
标签: java static-methods