S
Sunil
Hi ,
I have a method which takes a list of beans as parameter and does some
insertions into the database. I have something like this inside the
for loop:
for(int i=0;i<list.size();i++){
MyBean bean = new MyBean();
....................
....................
}
Initializing the bean inside the for loop is mandatory.
Will initializing the bean inside the for loop cause more memory
usage?
Or is this better?
MyBean bean = null;
for(int i=0;i<list.size();i++){
bean = new MyBean();
....................
....................
}
Which of the above two constructs is better?
My guess is both of them consume the same amount of memory. And there
is no difference in the performance either.
What do you think? Your suggestions are welocme.
Thanks & Regards,
Sunil.
I have a method which takes a list of beans as parameter and does some
insertions into the database. I have something like this inside the
for loop:
for(int i=0;i<list.size();i++){
MyBean bean = new MyBean();
....................
....................
}
Initializing the bean inside the for loop is mandatory.
Will initializing the bean inside the for loop cause more memory
usage?
Or is this better?
MyBean bean = null;
for(int i=0;i<list.size();i++){
bean = new MyBean();
....................
....................
}
Which of the above two constructs is better?
My guess is both of them consume the same amount of memory. And there
is no difference in the performance either.
What do you think? Your suggestions are welocme.
Thanks & Regards,
Sunil.