What I am trying to do is use method().method()
in the following code:
public class Practice {
public static void main(String[] args){
Message m = new Message("test");
m.append("in").append("progress").append("...");
m.printMessage();
}
}
My class Message is this:
public class Message {
private String astring;
public void append(String test) {
astring += test;
}
public Message(String astring) {
this.astring = astring;
}
public void printMessage() {
System.out.println(astring);
}
}
How can I use .append().append()
?
Change the method to the following:
public Message append(String test) {
astring += test;
return this;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With