i am using a java program and i need to store two sets of data (radius and thickness) there are elven of these i need to store. my question is firstly how to store these into an array without having to do user input each time. then say i need the radius and thickness of the third detector then how do i code for this. i know it is not clearly explained but any help apreciated.

Where will these pairs of numbers come from? A file or via user input?
If the numbers don't change often, then you could read them from a file that a user could fill in using an editor.
If there are two numbers that go together, you could create a simple class that holds the two numbers and same an instance of that class in an array. If that sounds too hard then you could use two arrays in parallel. By in parallel, in mean that the corresponding elements in the array at the same index are a pair. For example for the third pair:
radius[2] and thickness[2] would have the two numbers of the pair of data.

Edited 4 Years Ago by NormR1: n/a

thank you for your help
when you say put it in a file is it possible to put it in a .csv file and then have it read it. what i am doing is modeling particles in a detector and each detector has a radius and a thickness. and in my main code i need to be able to take these values from the array and use it in a loop so that the first time threw it use the first set of Radius and thickness and then on the second loop it use the next set of the radius and thickness. again any help incredible.

You could put the data into any kind of file that contains text data. A java program would be able to read it and convert its contents into numbers as long as the program knows what the order of the data is.
Once the data is read into arrays, then the program could use it one pair of data at a time.

This article has been dead for over six months. Start a new discussion instead.