Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
IBM : developerWorks : Java : Education - online courses
Java Collections Framework
Download tutorial zip fileView letter-sized PDF fileView A4-sized PDF fileE-mail this tutorial to a friend
Main menuSection menuGive feedback on this tutorialPreviousNext
6. Algorithm support
  


Manipulating elements page 5 of 6


The Collections and Arrays classes offer several ways of manipulating the elements within a List or array. There are no additional ways to manipulate the other key framework interfaces (Set and Map).

With a List, the Collections class lets you replace every element with a single element, copy an entire list to another, reverse all the elements, or shuffle them around. When copying from one list to another, if the destination list is larger, the remaining elements are untouched.

  • void fill(List list, Object element)
  • void copy(List source, List destination)
  • void reverse(List list)
  • void shuffle(List list)
  • void shuffle(List list, Random random)

The Arrays class allows you to replace an entire array or part of an array with one element via eighteen overridden versions of the fill() method. All the methods are of the form fill(array, element) or fill(array, fromIndex, toIndex, element).


Main menuSection menuGive feedback on this tutorialPreviousNext
PrivacyLegalContact