Ad Code

Difference Anonymous object and Named object?


What is the difference between Anonymous object and Named object? Give example with code.

We generally use anonymous object when there is just a one time use of a particular object but in case of a repeated use we generally used named objects and use that named reference to use that objects again and again.

Named
– String s = “hello”; System.out.println(s);
– “hello” has a named reference s.

Anonymous
– System.out.println(“hello”);
Reactions

Post a Comment

0 Comments