Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass an ArrayList as a parameter

Status
Not open for further replies.

skarosi

Programmer
Jan 25, 2004
140
0
0
GR
Hi all,
I have a small problem that i just cant understand!
I have created an ArrayList <String> and want to pass it to an other method. So i have this
Code:
   ArrayList<String> name = new ArrayList<String>();
.....
results(jComboBox1.getSelectedIndex(),ArrayList() name);
and then i have the result method,
Code:
public void results(int index,List table){}
I have tried all these and nothing is working!
Code:
public void results(int index,ArrayList table){}
Code:
public void results(int index,ArrayList<String> table){}

Any help pls? I am seriously thinking of having the list as a global variable! that would save me a lot of trouble!

 
Your first code snippet
Code:
results(jComboBox1.getSelectedIndex(),ArrayList() name);
should be like
Code:
results(jComboBox1.getSelectedIndex(), name);
And the second definition for the result method
Code:
public void results(int index,ArrayList<String> table){}
should be fine.

HTH
TonHu
 
How stupid of me!
I was just coping code from allover to make it to work, and didnt realize what i was actually writing!
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top