This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange behavior of length variable

 
Jagdev Singh
Ranch Hand
Posts: 71
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
During my preparation of assertions I came across the strange behavior of length variable for array.
When the code below is executed without commandLine arguments then it gives 0 as output.
But when line 2 is uncommented it gives nullPointerException, that is what I expect.
Why it is not giving any nullPointerException in the case of commandLine arguments.



Jagdev
 
dennis deems
Ranch Hand
Posts: 808
  • 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Command line arguments will never be null. If no argument is passed, there will simply be a zero-length array.
 
Harsha Smith
Ranch Hand
Posts: 287
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Null pointer exception because s is not initialized and is null.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic