Hi all,
Can anyone tell me how do I use toString() in user defined class. When I tried to compile the following code I got an error:
import java.lang.*;
class MyClass
{
static int maxElements;
MyClass(int maxElements)
{
this.maxElements = maxElements;
}
}
public class Q19
{
public static void main(
String[] args)
{
MyClass a = new MyClass(100);
MyClass b = new MyClass(100);
System.out.println(toString(a));
if(a.equals(b))
System.out.println("Objects have the same values");
else
System.out.println("Objects have different values");
}
}
Thanks in advance
Latha