public class InterfaceDemo {
public static void main(String[] args){
sendHttpRequests("你好梁钾,孤獨(dú)的人刘莹!", new HttpRequests() {
@Override
public void success(String response) {
System.out.println("訪問成功了呢刻坊!");
}
@Override
public void fail() {
System.out.println("訪問失敗哦!");
}
});
}
public static void sendHttpRequests(String address, HttpRequests httpRequests){
if (!address.isEmpty()){
httpRequests.success(address);
}else {
httpRequests.fail();
}
}
}
interface HttpRequests {
void success(String response);
void fail();
}