我刚刚安装了 ta4j Technical Analysis lib 。它有一个名为TimeSeries. 当我尝试实现第一种方法时TimeSeriesString getName()我收到以下错误:无法降低来自 TimeSeries implaments org.ta4jcore.Timeserios.GetName 的内在方法的可见性我的代码import org.ta4j.core.*;public class cMyChartVal implements TimeSeries { /** * @return the name of the series */ String getName() { return "TestSet"; } ..... .....}TimeSeries 接口类package org.ta4j.core;import java.io.Serializable;import java.time.format.DateTimeFormatter;import java.util.List;/** * Sequence of {@link Bar bars} separated by a predefined period (e.g. 15 minutes, 1 day, etc.) * </p> * Notably, a {@link TimeSeries time series} can be: * <ul> * <li>the base of {@link Indicator indicator} calculations * <li>constrained between begin and end indexes (e.g. for some backtesting cases) * <li>limited to a fixed number of bars (e.g. for actual trading) * </ul> */public interface TimeSeries extends Serializable { /** * @return the name of the series */ String getName(); /** * @param i an index * @return the bar at the i-th position */ Bar getBar(int i); /** * @return the first bar of the series */ default Bar getFirstBar() { return getBar(getBeginIndex()); } /** * @return the last bar of the series */ default Bar getLastBar() { return getBar(getEndIndex()); } /** * @return the number of bars in the series */ int getBarCount(); /** * @return true if the series is empty, false otherwise */ default boolean isEmpty() { return getBarCount() == 0; }
1 回答

HUH函数
TA贡献1836条经验 获得超4个赞
接口中的所有方法声明,包括静态方法,都是隐式公开的。它通常被省略。
实现类应该保留这个修饰符,而不是使用默认的类方法 modifer( package level)。
您可以将其更改为:
public String getName()
{
return "TestSet";
}
添加回答
举报
0/150
提交
取消