Is there any way in java to batch instantiate objects, initialize objects, and execute object methods?

for example:

ImageView imageview1;
ImageView imageview2;
ImageView imageview3;

imageview1=(ImageView)findViewById(R.id.main1);
imageview2=(ImageView)findViewById(R.id.main2);
imageview3=(ImageView)findViewById(R.id.main3);

imageView1.setVisibility(View.GONE);
imageView2.setVisibility(View.GONE);
imageView3.setVisibility(View.GONE);

if I use to generate multiple objects, how can I implement these in batches?


extract the common part into a method, and then call this method in a loop?


if you use android, you can try butterknife this open source library
to inject objects directly through annotations.

  

maybe you need dependency injection?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b389a3-2c11d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b389a3-2c11d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?