Tag: java arrays

Java Shuffle Array shuffle()

September 21, 2011 · 3 min read
Java [collections framework](http://way2java.com/collections/java-collections-framework/) comes with two classes [Collections](http://way2java.com/collections/collections-api-methods/) and [Arrays](http://way2java.com/collections/class-arrays-api-methods/) (from java.util) to operate on the elements of collection classes (data structures) and arrays. To shuffle the elements of a data structure, the Collections class includes a method **shuffle()** but [Arrays class](http://way2java.com/collections/class-arrays-api-methods/) does not come with one.

Sorting array elements sort() Comparator

September 13, 2011 · 1 min read
The earlier **sort()** example sorts implicitly in natural ascending order. The order can be customized with the overloaded sort() method that takes a [Comparator](http://way2java.com/collections/interface-comparator/) object as parameter.

class Arrays API Methods

August 18, 2011 · 4 min read
We have seen how [Collections class](http://way2java.com/collections/collections-api-methods/) methods made Java Programmer job easy to operate on data structure elements and we have discussed nearly 25 operations like comparing, sorting and searching etc. with good example codes. Now it is the turn with **Arrays** class. Almost the same methods exist with **Arrays** class but useful to perform on array elements. Array class was introduced with JDK 1.2 and placed in **java.util** package and forms a part of [collections framework](http://way2java.com/collections/java-collections-framework/). Before JDK 1.2, all the array elements manipulations (like shuffling, sorting and searching) were done by the developers from scratch level with enormous looping and if codes.
← Prev
Page 2 of 3
Next →