Results 1 to 6 of 6
Thread: Confusion over arrays
- 04-03-2009, 04:30 PM #1
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.Java Code:int maxarray=12;
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
:confused:
- 04-03-2009, 05:50 PM #2
Member
- Join Date
- Dec 2008
- Posts
- 41
- Rep Power
- 0
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.
Java Code:dateType[] array= new dataType[maxarray];
- 04-04-2009, 03:39 PM #3
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?
- 04-04-2009, 05:26 PM #4
Member
- Join Date
- Dec 2008
- Posts
- 41
- Rep Power
- 0
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.
- 04-04-2009, 05:37 PM #5
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?
- 04-04-2009, 09:38 PM #6
Member
- Join Date
- Dec 2008
- Posts
- 41
- Rep Power
- 0
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.
Similar Threads
-
[SOLVED] calling a boolean method, confusion!!
By AngrYkIdzrUlE in forum New To JavaReplies: 18Last Post: 03-15-2009, 10:23 AM -
[SOLVED] Confusion with classes (Please Help!)
By kbullard516 in forum New To JavaReplies: 8Last Post: 02-24-2009, 03:50 AM -
JList – A real confusion.
By darshak_patel in forum AWT / SwingReplies: 8Last Post: 02-07-2009, 12:17 AM -
System.in.read() confusion
By ankurdh in forum New To JavaReplies: 5Last Post: 01-08-2009, 08:28 AM -
bracket confusion...?
By gallimaufry in forum New To JavaReplies: 4Last Post: 10-28-2008, 11:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks