All pastes #826007 Raw Edit

Meins

public text v1 · immutable
#826007 ·published 2007-12-20 23:04 UTC
rendered paste body
 interface Schnitt {
	void g(Schnitt s);
	void h(Object o);
}

 class Ober implements Schnitt {
	public void g(Schnitt s) { System.out.print("X "); }
	public void h(Object o) { System.out.print("Y "); }
	public void h(Ober o) { System.out.print("Z "); }
}

 class Unter extends Ober {
	public void g(Unter u) { System.out.print("A "); }
	public void h(Object o) { System.out.print("B "); }
	public void h(Schnitt f) { System.out.print("C "); }
	public void h(Ober o) { System.out.print("D "); }
}

public  class Prog {
	public static void main(String[] args) {
		
		Unter u = new Unter();
		Ober o = new Ober();
		Schnitt s1 = u;
		Schnitt s2 = o;

		s1.g(s2);
		s1.h(u); // HERE
		s2.g(o);
		s2.h(u);
		u.h(u); // AND HERE
		u.h(o);
		o.g(u);
		o.h(s1);
		u.g(s1);
		s1.g(s1);

	}
}