aspose file tools*
The moose likes Servlets and the fly likes syntax for repeating a parameter in code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "syntax for repeating a parameter in code?" Watch "syntax for repeating a parameter in code?" New topic
Author

syntax for repeating a parameter in code?

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
I wondered if I have several videos is there a better way to state this?
instead of videoName1, et al etc.? Please see code below. Thanks - Michele
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

String[] videoNames; ???
Not sure what you're asking.
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
yes particularly in this code:



AND



Thanks, Michele
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Seems like a repetition of code for each videoName* variable. Can be shortened if you use an array: "String[] videoNames". Then interate throught the array: "for (String videoName : videoNames) { ... }" after it has been populated. Unless your code below is not complete or doesn't show the whole picture, videoName2 and videoName3 always seem to contain an empty String.
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
like this:

"{\"name\":\"" + int [] videos = { OS_FILE, AV_FILE, VT_File }; + "\", " +

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

You do know how to use a loop, do you? You then create one, and put all the code you now have three times inside that loop once.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
Can you help me get started?

Thanks,
Michele
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: syntax for repeating a parameter in code?