public class InterfaceDemo {
public static void main(String[] args){
sendHttpRequests("你好,孤独的人!", 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();
}