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

Variable Argument Lists Question

 
Yin Stadfield
Ranch Hand
Posts: 58
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I know I ask a lot. lol I just want to really understand this stuff inside-out so I could pass the OCJP, please bear with me. Thanks.

My study book is SCJP Sun Certified Programmer for Java 6 Study Guide Exam 310-065 by Kathy Sierra and Bert Bates. I'm a bit confused about something that is written about Variable Arguments Lists.
I will write the paragraph and mark the one that I have trouble in understanding:

- Var-arg type. When you declare a var-arg parameter, you must specify the type of the argument(s) this parameter of your method can receive. (This can be a primitive type or an object type.) //Got it
- Basic syntax. To declare a method using a var-arg parameter, you follow the type with an ellipsis (...), a space, and then the name of the array that will hold the parameters received. //Got it
- Other parameters. It's legal to have other parameters in a method that uses a var-arg. //Um, can anyone rephrase this for me? I don't get it. . I thought it can only have one var-arg in a method.
- Var-arg limits. The var-arg must be the last parameter in the the method's signature, and you can have only one var-arg in a method. //Got it


Thanks.
 
Praveen Kumar M K
Ranch Hand
Posts: 256
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that there can be other parameters in the method signature along with var-args parameter.

E.g.: void varArgsMethod(float param1, String param2, Integer...varargParam)
 
Mrinal Singhania
Greenhorn
Posts: 7
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praveen Kumar M K wrote:It means that there can be other parameters in the method signature along with var-args parameter.

E.g.: void varArgsMethod(float param1, String param2, Integer...varargParam)


However, the var-args parameter should be last in the parameter list.
 
Yin Stadfield
Ranch Hand
Posts: 58
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mrinal Singhania wrote:
Praveen Kumar M K wrote:It means that there can be other parameters in the method signature along with var-args parameter.

E.g.: void varArgsMethod(float param1, String param2, Integer...varargParam)


However, the var-args parameter should be last in the parameter list.


Just got confused, thanks for clearing things up Praveen and Mrinal!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic