public string tostring 28 29 7b

Solutions on MaxInterview for public string tostring 28 29 7b by the best coders in the world

showing results for - "public string tostring 28 29 7b"
Rudy
06 Jun 2019
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}