实现接口时出现错误“无法降低继承方法的可见性”

我刚刚安装了 ta4j Technical Analysis lib 。它有一个名为TimeSeries. 当我尝试实现第一种方法时TimeSeries


String 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;

    }



慕妹3242003
浏览 290回答 1
1回答

HUH函数

接口中的所有方法声明,包括静态方法,都是隐式公开的。它通常被省略。实现类应该保留这个修饰符,而不是使用默认的类方法 modifer( package level)。您可以将其更改为:public String getName(){&nbsp; &nbsp; return "TestSet";}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java