1public class MyClass{
2
3 // An example class with two arbitrary attributes
4 private int myInt = 5;
5 private String myString = "Hello World";
6
7 // toString() is defined by default in Java, so the @Override is necessary
8 @Override
9 public String toString(){
10 // Note that the result string can be anything you want
11 return "MyClass Object (%s, %d)".format(this.myInt, this.myString);
12 }
13}