in Objective-C we can define a protocol and a implementation in the same header file. For example:
@class GamePickerViewController;
@protocol GamePickerViewControllerDelegate <NSObject>
- (void)gamePickerViewController:
(GamePickerViewController *)controller
didSelectGame:(NSString *)game;
@end
@interface GamePickerViewController : UITableViewController
@property (nonatomic, weak) id <GamePickerViewControllerDelegate> delegate;
@property (nonatomic, strong) NSString *game;
@end
This way if I include the .h file I will have access to the protocol defined inside the file. I'm looking for a similar structure in Java cause I find it useful in some cases where I would like to avoid creating too many files (interface file+class file). That way I could declare:
public class MyImplementation implements AnotherClass.MyInterface{
AnotherClass otherClass;
}
I Think nested classes inside interfaces is the way to go. I am correct? or there's nothing similar in Java?