简体   繁体   中英

must either be declared abstract or implement abstract method

I get the following message when trying to implement a class:

在此处输入图片说明

public class MyLocationListener implements BDLocationListener

This sentence is wrong. The hint is:Class 'MyLocationListener' must either be declared abstract or implement abstract method 'onConnectHotSpotMessage(String, int)' in 'BDLocationListener

I use Android Studio.

You are declaring that you're going to "implement BDLocationListener" which is an abstract class.

When you implement an abstract class, you must provide a method for every unimplemented abstract method within the abstract class. In this case, onConnectHotSpotMessage(String, int) is one of the abstract methods in that class.

You must either provide an implementation of this method in your MyLocationListener class or declare your MyLocationListener as an abstract class. If you declare MyLocationListener as an abstract class, you will not be able to instantiate it, so it is more likely that you want to implement the method.

Your BDLocationListener class has an Abstract method that needs to be implemented in your MyLocationlistener , it's like a contract, if a class wants to implement an abstract class it has to implement its abstract methods or to be abstract as well.

You can find more information about Abstract class here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM