View Single Post
  #3 (permalink)  
Old 01-22-2008, 11:22 AM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Dynamic data structures
Hello bluefloyd8

Arrays are not dynamic data structures and you cannot make them (that easily). You need to specify their size before you use them. Your compiler probably gave you a null pointer exception, right? So change you code to:
Code:
public static final int structureSizeLimit = 10000; private ParsedSiteInfo[] parsedInfo = new ParsedSiteInfo[structureSizeLimit]; private int sites = 0; private void createNewSite() { this.parsedInfo[this.sites] = new ParsedSiteInfo(); this.sites++; }
Remember to check this limit each time you try to add elements. See this tutorial on vectors and other dynamic data structures.

Good luck.
__________________
If your ship has not come in yet then build a lighthouse.
Reply With Quote