Java Puzzle : Function parameters
Here is another Java puzzle, but this time you don’t need to find output of this program. Instead just complete the code snippet to get desired output.
Here is the program :
public class OPuzzle {
public static void main(String[] args) {
Object o = null;
printMe(o);
}
private static void printMe(<Provide the declaration here> o){
if(o!=null){
System.out.println("I am not null");
}
}
}
Desire output :
I am not null
Replace the <Provide the declaration here> with appropriate declaration to get above desired output. Leave your comments.
Reference : http://google-opensource.blogspot.com/2011/04/geek-time-with-josh-bloch.html
No no no … don’t see reference before solving :).
The answer is
ReplyDeleteprivate static void printMe(Object... o){//..}
What is the answer bro..???
ReplyDeleteThe answer is already mentioned inn previous comment.
ReplyDelete