public interface MyInterface extends Interface1, Interface2 { double E = 2.718282; void doSomething (int i, double x); int doSomethingElse(String s); } public class MyClass implements MyInterface { public void doSomething(int i ,double x) { [...] } public int doSomethingElse(String s) { [...] } public static void main(String args[]) { MyInterface m = new MyClass(); //Interface utilisée comme type m.doSomething(4,2.1); } }
ArrayList<Form> formList = new ArrayList<Form>(); formList.add(new Square(aPoint, 10)); formList.add(new Line(aPoint, anotherPoint)); [...] foreach(Form f : formList) { f.doSomething(); // Appel polymorphique }
public abstract class AnAbstractClass{ private int aFied; [...] public void doSomething(){ [...] } public abstract void doAnotherThing(); }
Person p = new Assistant([...]); [...] Assistant a = (Assistant)p;
public class A { public A() { [...] } } public class B extends A { public B(){ [...] } } public class C extends B { public C(){ [...] } }
Lors de la construction d’un objet de la classe C :
protected void finalize() throws Throwable { try { close(); // close open files } finally { super.finalize(); } }
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |