Question: **This is my class containing setters and getters**

```
package Pack;

public class Details {

String FirstName,LastName,City,Country;

    public Details(String firstName, String lastName, String city,
            String country) {
        super();
        FirstName = firstName;
        LastName = lastName;
        City = city;
        Country = country;
    }

    public String getFirstName() {
        return FirstName;
    }

    public void setFirstName(String firstName) {
        FirstName = firstName;
    }

    public String getLastName() {
        return LastName;
    }

    public void setLastName(String lastName) {
        LastName = lastName;
    }

    public String getCity() {
        return City;
    }

    public void setCity(String city) {
        City = city;
    }

    public String getCountry() {
        return Country;
    }

    public void setCountry(String country) {
        Country = country;
    }
}

```

===========================================================================

This is my main()

```
package Pack;

public class MainClass {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Details d = new Details("Hari","L","Bangalore","India");

    }

}

```

==========================================================================

I know my main() is incomplete. What should i write to display the contents of "d"?

Answer: 
There are two ways.

One, just print each property of your details object :

`System.out.println("FirstName :"+d.getFirstName());` etc..

Or, a better option would be to override `toString()` method in your class 

```
public void toString() {
        return this.getFirstName()+ " " + this.getLastName()+" "+.... ;
}

```

and then just print your class `System.out.println(d);`
you need a toString() method in Details class:

```
public String toString(){
   return this.firstName + " " + this.lastName + ", " + this.city + " " + this.country;
}

```

and 

```
System.out.println(d.toString());

```

in main