title: How to override the ToString method of ArrayList of object?
body: <pre><code>class Person {
    public String firstname;
    public String lastname;
  }
  
  Person p1 = new Person("Jim","Green");
  Person p2 = new Person("Tony","White");
  
  ArrayList&lt;Person&gt; people = new ArrayList&lt;Person&gt;();
  
  people.add(p1);
  people.add(p2);
  
  System.out.println(people.toString());
  </code></pre>
  
  <p>I'd like the output to be <code>[Jim,Tony]</code>, what is the simplest way to override the <code>ToString</code> method if such a method exists at all?</p>