Created
November 18, 2014 10:10
-
-
Save peczenyj/187610c6e68f45062525 to your computer and use it in GitHub Desktop.
toString example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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