Online Java Compiler By
JavaTpoint.com
public class JavaObjecttoStringExample2 { static int a = 10, b=20; int c; // Constructor JavaObjecttoStringExample1() { System.out.println("Addition of 10 and 20 : "); c=a+b; System.out.println("Answer : "+c); } // Driver code public static void main(String args[]) { JavaObjecttoStringExample1 s = new JavaObjecttoStringExample1(); System.out.println(s.toString()); } }
Output