File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 382
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: 382
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: 382
like this:

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

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19545
    
  16

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: 382
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?
 
Similar Threads
Need to hook two servlets together, how do I do that?
New Servlet, Has a One Errors on it
Help Package Servlet Error
Help Modifying Servlet Please
Getting java.io.FileNotFoundException:(The system cannot find the file specified) error