Skip to content

Thursday Java programming challenge, let's see who cracks it 😀. Method overloading using null. #799

Closed Answered by aysha-siddqua
im-ahmed-hasan asked this question in Q&A
Discussion options

You must be logged in to vote

The code actually won’t compile. When you call test(null), Java can’t decide between String and int, both are valid matches for null and neither is more specific than the other. So the compiler throws an ‘ambiguous method call’ error.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by im-ahmed-hasan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants