It's not a secret anymore!*
The moose likes Servlets and the fly likes 2D Array of Strings as Output parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "2D Array of Strings as Output parameters" Watch "2D Array of Strings as Output parameters" New topic

2D Array of Strings as Output parameters


Joined: Dec 27, 2000
Posts: 11
Hi Guys,
Am still working on converting my SingleThreadedModel servlet into a MultiThreaded one. Just need help on one problem i got here.
pls consider below code.
private int main_func()
StringBuffer[][] xx=null;
int r=sub_func(xx);
some code here printing the contents of xx list....
private int sub_func(StringBuffer[][] xx)
some code here.... solve ncodes
xx = new StringBuffer[ncodes][2];
some code here filling up the xx arraylist.
Initially (when the code was still a SingleThreaded one), I have xx array list as an Instance variable of the servlet, i did not have this problem. But since (as suggested) a MultiThreaded servlet requires me to have this variable as a local variable (NOT use instance variables), I have created xx as a local variable of the calling method- main_func. Problem now is I can't seem to "pull-out" the populated version of the variable xx from sub_func method. I always get the "null" version/unpopulated one. In C, I can do this by passing the base address of the variable xx from main_func to sub_func and allow sub_func to allocate the mem space and populate the xx list. Is there anyway in java i can do this? pls help thanks.

Joined: Dec 27, 2000
Posts: 11
Hi guys,
this problem is solved already. I used an inner class which has arraylist as components instead of the 2D array. It worked! Thanks!
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
Please note that The Java Ranch has a naming policy, described here and "Tano_Ortiga" is not a valid name as it has an "_" in it.
Please choose one which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: 2D Array of Strings as Output parameters
Similar Threads
Synchronizing without blocking in a servlet filter
Sun Cirtification
Fast text searching
Basic object creation
Multi-threaded servlet