Question about updating array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Question about updating array

I use array to store data and I get this data in many methods including JButton ActionEvent by using the statement ~record [] record = new record[100];~. How to store new data to the array so that the data can be updated in other method in the same time? I also use set and get method to create the array.

23rd Nov 2016, 12:08 PM
Cheung Kim Fung
Cheung Kim Fung - avatar
3 Answers
+ 2
i think you should complete the java course first
23rd Nov 2016, 1:06 PM
Roland
0
one way is to pass it over to the method that needs the records. i.e. Record [] record = new Record[100]; // ... some code here myFunction(record); private void myFunction(Record[] input){ // now i can manipulate the record input[0] = new Record(); .... }
23rd Nov 2016, 12:19 PM
Roland
0
What is myFunction?
23rd Nov 2016, 12:44 PM
Cheung Kim Fung
Cheung Kim Fung - avatar