Advanced Concepts
- A
Function
is an object's type similar to other objects:
public class Funs {
public interface Fun { public int apply(int x); }
public static void main(String[] args) {
Fun abs = new Fun() { public int apply(int x)
{ return (x>=0)?x:-x; }};
System.out.println(abs.apply(-3));
}
}
And with types' parameters:
public interface Fun<X,Y> { public Y apply(X x); }
public static void main(String[] args) {
Fun<Integer,Integer> abs = new Fun<Integer,Integer>()
{ public Integer apply(Integer x) { return (x>=0)?x:-x; }};
System.out.println(abs.apply(-3));
}
4 - 17Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented