Re: Interesting Java interview question
- From: Jack <jack@xxxxxxxxxxx>
- Date: Thu, 13 Mar 2008 21:59:52 +0100
Joshua Cranmer a écrit :
Why does the following compile, and what does the output look like?
System.out.println(new Object(){{{}}}.toString());
I would say that the output depends on some unprovided code. For example, if the following file were used:
public class InterviewQuestion {
public static void main(String... args) {
System.out.println(new Object(){{{}}}.toString());
}
}
it should print out `InterviewQuestion$1@<hex value>` where hex value will be the hash code of said object.
Why not "Object@<hex value>" ?
.
- Follow-Ups:
- Re: Interesting Java interview question
- From: Joshua Cranmer
- Re: Interesting Java interview question
- Prev by Date: Re: What do Java programmers feel is missing from C#?
- Next by Date: Re: Interesting Java interview question
- Previous by thread: JSP Bean retrieval
- Next by thread: Re: Interesting Java interview question
- Index(es):