NichtHaskell/Examples/FieldAccessAndMethodCalls.java

40 lines
672 B
Java
Raw Normal View History

2024-07-04 09:07:22 +00:00
class FieldAccessAndMethodCalls {
2024-07-04 09:04:33 +00:00
public static void main(String[] args) {
Class1 c1 = new Class1();
int i = c1.c2.c3.m3(1).m2().m1();
print(i);
}
}
2024-07-04 09:07:22 +00:00
class Class1{
2024-07-04 09:04:33 +00:00
int i1;
Class2 c2;
2024-07-04 09:07:22 +00:00
public Class1() {
2024-07-04 09:04:33 +00:00
this.c2 = new Class2();
}
public int m1(){
return i1;
}
}
2024-07-04 09:07:22 +00:00
class Class2{
2024-07-04 09:04:33 +00:00
int i2;
Class3 c3;
2024-07-04 09:07:22 +00:00
public Class2(){
2024-07-04 09:04:33 +00:00
this.c3 = new Class3();
}
public Class1 m2(){
2024-07-04 09:07:22 +00:00
Class1 c1 = new Class1();
2024-07-04 09:04:33 +00:00
c1.i1 = i2;
return c1;
}
}
2024-07-04 09:07:22 +00:00
class Class3{
2024-07-04 09:04:33 +00:00
int i3;
public Class2 m3(int i){
Class2 c2 = new Class2();
c2.i2 = i;
return c2;
}
}