我有2類:鏈接方式,方法
public class A {
private final List<String> list;
public A() {
list = new ArrayList<String>();
}
public A first(String s) {
list.add(s);
return this;
}
public A second() {
System.out.println(list);
return this;
}
}
public class B extends A {
public B bfisrt() {
System.out.println("asd");
return this;
}
}
,並在主要的工作與主,下面的代碼類
B b = new B();
b.first("unu")
.second();
b.bfirst();
,但我想要在同一個對象上鍊接兩個類的方法。這是可行的嗎?像
B b = new B();
b.first("unu")
.second()
.bfisrt();
也嘗試一下,看看它有可能.. – nafas