小编jso*_*fry的帖子

Java:调用一个调用重写方法的超级方法

public class SuperClass
{
    public void method1()
    {
        System.out.println("superclass method1");
        this.method2();
    }

    public void method2()
    {
        System.out.println("superclass method2");
    }

}

public class SubClass extends SuperClass
{
    @Override
    public void method1()
    {
        System.out.println("subclass method1");
        super.method1();
    }

    @Override
    public void method2()
    {
        System.out.println("subclass method2");
    }
}



public class Demo 
{
    public static void main(String[] args) 
    {
        SubClass mSubClass = new SubClass();
        mSubClass.method1();
    }
}
Run Code Online (Sandbox Code Playgroud)

我的预期输出:

子类method1
超类method1
超类method2

实际产量:

子类method1
超类method1
子类方法2

我在技术上知道我已经覆盖了一个公共方法,但我认为因为我正在调用super,所以超级中的任何调用都会保留在super中,这种情况不会发生.关于如何实现这一点的任何想法?

java inheritance overriding super

86
推荐指数
4
解决办法
9万
查看次数

Google Vision条形码检测库未在某些设备上安装

我正在使用新的Google Play服务视觉库编写应用程序以检测条形码.

在我测试过的大多数设备上一切正常,但是一个特定设备拒绝安装本机库(在此评论中提到)

// Note: The first time that an app using the barcode or face API is installed on a
// device, GMS will download a native libraries to the device in order to do detection.
// Usually this completes before the app is run for the first time.  But if that
// download has not yet completed, then the above call will not detect any barcodes
// and/or faces.
//
// isOperational() can be used to check if …
Run Code Online (Sandbox Code Playgroud)

android google-play-services google-vision android-vision

7
推荐指数
1
解决办法
2045
查看次数