Collections.nCopies(numberOfCopies, objectToCopy);

The nCopies method us not used offenly but it is very helpful if you have to create copy of an object or an number .

Suppose you are working with jdbc and you have to use PreparedStatmenet to udpate a table with 100 columns so you have to write 100 times ‘?’  like ‘?,?,?,…’ these is a burden when we use preparedstatmenet and statement .

Collections.nCopies(100,’?’) is the answer of these problem  it will write 100 times ‘?’.

I hope you like it

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s