• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can multiple parameters be passed in this type of String?  RSS feed

 
Papi Escobar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can multiple parameters be passed in this type of String? in addition to filenamSet can you add additional parameters? If so how is the statement constructed?

 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you must pass one argument which is a Set of Strings. You can write a different method with several parameters, yes.

Which statement do you mean? There is only one statement in the code you posted, the if statement. But I am sure you already know what it means.
There is some bad design there, and bad style because you are missing {}. If you receive a null parameter which you don't want, you are far better off throwing an Exception.
 
Papi Escobar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:No, you must pass one argument which is a Set of Strings. You can write a different method with several parameters, yes.

Which statement do you mean? There is only one statement in the code you posted, the if statement. But I am sure you already know what it means.
There is some bad design there, and bad style because you are missing {}. If you receive a null parameter which you don't want, you are far better off throwing an Exception.


Can I pass multiple strings in the Set? For Example: (Set<String> filenameSet, directoryname)

The curley braces were left off in error I only wanted to post a snippet of the code.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably ARE passing multiple strings in the set. They are probably all file names.

If you want to pass a single directory in, you can, but you'd have to create an overloaded method that takes both parameters. something sort of like:

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!