I have been asked to Override the method toString of MyClass using StringBuilder and I have to append some text in red so it will look like that:
Name: Tom
Surname: Baker
Age: 17 --> Text in Red
Code:
@Override
public String toString(){
StringBuilder sb = new StringBuilder;
sb.append("Name:"+this.name+"\n");
sb.append("Surname:"+this.surname+"\n");
sb.append("Age:"+this.age+"\n");
return sb.toString();
}
Edit
Thank you for your answers.
The program is for a university assignment and it is being coded using Eclipse.
It is basic Java (not RXJava)
The output will be visualised through the console.
The teacher ask that but I feel it is not possible.