I have two arrays of two value objects
class VO1 {
String name;
String age;
//getter methods
//setter methods
}
class VO2 {
String name;
String age;
//getter methods
//setter methods
}
VO1[] objArry1 = VO1[10];
VO2[] objArry2 = VO2[20];
Assuming that both these arrays are populated, i am creating a third array of value objects by using these two arrays
ThirdVo[] objArry3 = ThirdVo[30];
For populating the thrird VO i am using for loop and getter methods of value object.
e.g
for (int i = 0; i<objArry1.length; i++) {
VO1 tempOBj = objArry1[i];
ThirdVo obj = new ThitdVo();
obj.setName(tempObj.getName());
obj.setAge(tempObj.getAge());
objArry3[i]= obj;
//for gc
objArry1[i] = null
}
//for gc
objArry1 = null; //as my objects are copied in ThirdVo and i don't want it further in the code
My Question
1.is the line after //for gc is really necessary
2.is it a good practice to make obj reference to explicitly to null
regards
prashant
objArry1[i] = nullobjArry1 = null;