Skip to content

Instantly share code, notes, and snippets.

@peczenyj
Created November 18, 2014 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peczenyj/187610c6e68f45062525 to your computer and use it in GitHub Desktop.
Save peczenyj/187610c6e68f45062525 to your computer and use it in GitHub Desktop.
toString example
import java.util.*;
public class A {
String name;
public A(String name) { this.name = name; }
public String toString(){ return "A[" + this.name + "]"; }
public static void main ( String [] args ) {
List<A> as = new ArrayList<>();
as.add( new A("huguinho"));
as.add( new A("zezinho"));
as.add( new A("luizinho"));
for( A a : as ){
System.out.println(a);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment