I am writing Java app.
This is a sample of my code:
int [] digitPart_1 ={16,7,9,8,5,6,};
int [] digitPart_2 ={1,77,98,86,5,6,};
int [] digitPart_3 ={166,7,49,84,55,6,};
for(int i = 0; i < mfl.size(); i++){
new DataProcessing(digitPart_+""+(i + 1));
}
In my design now each part (e.g. digitPart_1) shall be passed in, because 0 + 1 = 1, 1 + 1 = 2, i.e. digitPart_1 etc. But that causes compile error. It does not let me modify the name of array I pass in.
The ‘mfl’ is not important, it shall store number 3. I was just wondering whether I can modify the the name of data-structure I pass in dynamically like you can modify string you pass in to the output stream.
Any suggestion on how to overcome this issue?
Cheers
you cannot modify varaibles’ name dynamically. but you can use an array instead: