Home > Java > Core Java: Collections Framework and AlgorithmsCore Java: Collections Framework and Algorithms Eugenia Loli 2005-02-28 Java 6 CommentsThis sample book chapter shows how Java technology can help you accomplish the traditional data structuring needed for serious programming, and introduces you to the fundamental data structures that the standard Java library supplies.About The Author Eugenia LoliEx-programmer, ex-editor in chief at OSNews.com, now a visual artist/filmmaker.Follow me on Twitter @EugeniaLoli 6 Comments 2005-03-01 12:30 am the collections are very useful.and more useful when you realise you can put your own objects into the data structures – as long as you implement the very simple comparison funcions you can very easily use the java supplied algortihms such as sort(). 2005-03-01 1:31 am The fact that primitive types are not objects requires all kinds of contortions to store them in collections. For example, take a look at java/util/Arrays.java in the JDK source. Its so bad its laughable — the sorting algorithm is duplicated once for each type of primitive array, and the only difference is the static type signature.On the other hand, if you use collections instead of primitive arrays, another problem comes into play: wasted memory due to boxing overhead.In Common Lisp, everything is an object, even numbers. Furthermore, you can allocate so-called “specialized arrays”, which behave exactly like normal arrays, except they can only hold one type, and hold it efficiently. For example a specialized array of floats behaves like a high level collection, but is very memory efficient. 2005-03-01 1:51 pm Yes, but CLISP is never going to have the widespread usage of Java. (And(I am very glad of)that)! 2005-03-01 3:14 pm first of all, i cant remember the last time i used an array, let alone an array of primitives. so for us its a non-issue, our app is full of ArrayLists of container beans. 2005-03-01 11:11 pm Depends on what kind of work you do. I for one can’t remember the last time I had to rely on a collection of primitives, but I work with multidimensional arrays of primitives daily. 2005-03-02 12:14 am yeah, this is true. im not saying that primitive/object relationships couldnt have been handled better, but i wouldnt say its a critical flaw, at least to most people.and boxing does give you some overhead, but how bad is it? its another few bytesand correct me if im wrong, but couldnt you implement the functionality your talking about by writing your own? extend AbstractList, and make your own specialized collections? if the only problem is the lack of polymorphism for primitives, then an IntArrayList shouldnt be too hard.