By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,798 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,798 IT Pros & Developers. It's quick & easy.

Copy and expand an array

P: 1
I am trying to copy values from an array in a parent class into an expanded array in a subclass. Here is my code so far:

public class AblistWithOccurances extends Ablist

public AblistWithOccurances ()
{
super(); //Copy Constructor
}

public int expandedList(String[]listItems,int []maxItems, int values)
{
int []expandedList = new int[(maxItems.length + 100)];
}
for(int i=0;i<(maxItems.length + 100); i++)
{
expandedList[]=listItems.Ablist[];
return expandedList;
}

I am getting an illegal start of expression error message in regards to my "for" loop.
Dec 7 '06 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,510
remove the } indicated the compiler thinks it has come to the end of method expandedList()
Expand|Select|Wrap|Line Numbers
  1. public int expandedList(String[]listItems,int []maxItems, int values)
  2. {
  3. int []expandedList = new int[(maxItems.length + 100)];
  4. }    << remove this !!
  5. for(int i=0;i<(maxItems.length + 100); i++)
  6. {
  7. expandedList[]=listItems.Ablist[];
  8. return expandedList;
  9. }
  10.  
Dec 7 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.