Object.toString() has the following syntax.
public String toString()
In the following code shows how to use Object.toString() method.
import java.util.ArrayList; //from w w w .j a va 2s .c o m public class Main { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add(50); System.out.println(list.toString()); } }
The code above generates the following result.