myObjec.httpReq(url, postData, callbackFunct, callbackParam, callbackFailFunct, new MyInterface() { @Override public void myMethod() { } });
MyInterface foo = new MyInterface(); // Compile-time error.
MyInterface myInterface = new MyInterface() { public void doStuff() { //here is your implementation } public void doAnotherStuff() { //Note that this method is public, but //you're still not able to call it from outside of this class //because it's not part of MyInterface's contract } };
MyInterface myInterface= new MyInterface() { @Override public int myMethod() { return 1; } }
@Module public class MyModule { @Provides MyInterface providesMyInterface() { return new MyInterface() { // my super awesome implementation. MIT license applies. }; } }
myFunction(new MyInterface() { void method() { // Your code here } });
MyInterface myInterface = new MyInterface() { @Override public int foo(String bar) { ... return someIntVar; } }
MyInterface o = new MyInterface() { public Object myMethod(Object blah) { return "bar"; } };
MyInterface myInterfaceImpl = new MyInterface() { public void myInterfaceMethod() { // add method implementation here } }
public class MyClass extends MySuperClass implements MyInterface{ MyInterface myInterface = new MyInterface(){ /* Overrided method from interface */ @override public void method1(){ } }; /* Overrided method from superclass*/ @override public void method1(){ } }
myEntity.myInterface = new MyInterface() { @Override public void customFunction(int value) { //This is my custom function. //This can be different for every instance of MyEntity class } };
public static void main(String args[]) { try { myMethod(new MyInterface (){ public void doThis() { //do something...; }}); } catch (Throwable t) { } }
x = new MyInterface() { overriddenMethod() { // .... } } v = x.overriddenMethod();
MyInterface myInterface = new MyInterface() { public void requiredMethod(...) { //... } };
public class MyClass extends MySuperClass implements MyInterface{ MyInterface myInterface = new MyInterface(){ /* Overrided method from interface */ @override public void method1(){ } }; /* Overrided method from superclass*/ @override public void method1(){ } }
this.variable = new MyInterface() { public void myMethod() { ..... } };
MyInterface o = new MyInterface() { @Override public void myFunction() { System.out.println(someString); } };
@Module public class MyModule { @Provides MyInterface providesMyInterface() { return new MyInterface() { }; } @Provides MyClassUsingMyInterface providesMyClass(MyInterface myInterface) { return new MyClassUsingMyInterface(myInterface); } }
public class MyClass { MyInterface o = new MyInterface() { @Override public void myMethod() { System.out.println("In my method"); } }; public void doSomething() { o.myMethod(); } }
MyInterface var = new MyInterface() { public MyClass anyMethodName() { return new MyClass(); }