Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

println() : question from JQPlus

 
geetha nagarajan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will happen when this code is compiled and run?

Acc.to JQPlus,the answer is the code won't compile.
I tried the above code ,it compiles and runs printing : nullnull
nulltrue
truenull

In this case,it gives a compiler error ,as it's an ambiguous reference : bcos println() can take both char[] & String as parameters.
Could someone clarify these 2 cases ?
Thanks in advance.
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1st case:
I tried to compile it, but got the following compile-time errors:

2nd case
Sorta self explanitory by the error message isn't it? if you change the code to this (and avoid the ambiguity) things compile/run fine:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic