当我需要在iOS中实现协议的特定对象时,我写道:
-(void)someMethodWithObject:(SpecificObjectType<SomeProtocol>) object;
此代码是否存在Android等效项?
答案 0 :(得分:1)
是的,在Java(Android主要语言)中,您将使用Interface:
来实现创建接口(SomeProtocol)
public interface SomeProtocol {
public void someMethodWithObject();
}
创建实现接口的对象
public class SepcificObjectType implements SomeProtocol {
public void someMethodWithObject() {
// Implement your logic here
}
}