File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parameter passing into a method-Examlab

 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
source:Examlab 1




1) why invoking method with one argument compiles and runs fine at line 1
even though we are asking for 2 parameters to be passed in the function getFormattedObject()
2) while at line 2 we are passing two parameters it compiles and gives IllegalStateException
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sumit kothalikar wrote:

1) why invoking method with one argument compiles and runs fine at line 1
even though we are asking for 2 parameters to be passed in the function getFormattedObject()

Since, the second paremeter is in the form of var-args, you can pass zero or more arguments! In your case, zero arguments!
 
Simone Aiello
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sumit kothalikar wrote:source:Examlab 1
1) why invoking method with one argument compiles and runs fine at line 1
even though we are asking for 2 parameters to be passed in the function getFormattedObject()
2) while at line 2 we are passing two parameters it compiles and gives IllegalStateException



The code above calls the group() method on Matcher mt1 two times. Hence it throws an illegalStateException;
The second time there is no matches found...

If you comment either line 14 or 15 (adjusting the system.out ) the code compiles fine and doesn't throws any exceptions.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic