Hi,
I got this code from the internet and i compiled it. But i dont understand the result. Could u explain the result ? I cant figure out the output that shows 'classname@somenumbers' .

thz

public class Andy
{
	public static final Andy nd= new Andy();
	
	private Andy()
	{
	}
	public static void main(String args[])
	{	System.out.println(Andy.nd);
	}
}

Recommended Answers

All 3 Replies

you create a reference to a new object (nd). then you ask your computer to print this object, but since you don't specify what should be printed, it just prints the reference to this object.

maybe you'll learn more if you try to change or add some methods and testing these out, than just by copying some code of the net and running it

he didn't ask you. He asked someone called "u" who last I checked wasn't a member here.

he didn't ask you. He asked someone called "u" who last I checked wasn't a member here.

hehe

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.