Java Object.toString()

Syntax

Object.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use Object.toString() method.


import java.util.ArrayList;
//from  ww  w  . j  a  va 2  s.  com
public class Main {

   public static void main(String[] args) {
      ArrayList list = new ArrayList();
      list.add(50);

      System.out.println(list.toString());
   }
}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable