Confusion over arrays
I am relatively new to java and my understanding of arrays
I am in the middle of a project that calculates the bmi, everything works so far apart from I want to limit the amount of records that can be added, unfortunately I think im misunderstanding the following:
Now as I understand it that is telling me that the array will only handle 12 records......as this doesnt work maybe someone would be kind enough to let me know what it is telling me.
I have a text file that I want to add the records but I want it to flag up an error once I have reached the limit, in this instance I thought setting it at 12 would allow for a quick test as the figure will be 250.
Thanks in advance if someone can answer either or both questions
int maxarray=12; is just making an int data type that is initialized with a value 12. To use this where u declare your array you should have a line like this.
dateType array= new dataType[maxarray];
So I am looking in the wrong place then, I should be setting a limit on the records that I can input into my .txt file then?
you could use a loop that iterates 12 times. if you wouldnt mind i could help you a little better if you posted all the code.
I would be grateful for your help, however the code is a total of 1291 lines so just to check so you only get the code you need to look at
I have several buttons on the gui at the moment
Search, add, next, update, new file, first record.
I am close to being able to get rid of the next button however where would this loop go.
The app calculates a persons bmi using either metric or imperial measurements, generates a file where members details are stored, I want to set the loop for 25 and then i want the optionPane to kick in to advise file full, EOF.
So which button would you say the loop needs to go in? or does it need to go in the public class?
What you could do is write a while loop in the main method that gets the information from the user. declare a global array of BMI obects and store the new object in the array at the end of the loop. As for the EOF you could use a similar loop to write the objects to a file and when u reach the limit that you want throw an EOF Exception. let me kno if im on the right track for what u want the program to accomplish.