更新时间:2022-12-13 23:26:57
从您的问题来看,您所寻找的事情很简单委托:
From your question it sounds like the thing you are looking for is simple delegation:
class MyString {
String delegate; // The actual string you delegate to from your class
public MyString(String delegate) {
this.delegate = delegate; // Assign the string that backs your class
}
int length() {
return delegate.length(); // Delegate the method call to the string
}
// other methods that delegate to the string field
}