We all know that the method public static List asList(T... a) in Arrays class returns an ArrayList.
But if you try to add or remove an element on this returned arrayList, you get an UnsupportedOperationException. Why?
This is because the returned ArrayList is not of type java.util.ArrayList, instead, it is java.util.Arrays$ArrayList class. And this java.util.Arrays$ArrayList class does not override all the methods of AbstractList class.
That means Arrays.asList() returns you a fixed size list.
Refer this link http://tinyurl.com/26mxkxm for complete article.
I will share here few basics, tweaks, solutions and approaches as per my knowledge on eclipse, java and related technologies. Don't hesitate to jot down a comment, u like it or don't like it, or want to correct me.
Monday, May 17, 2010
Monday, May 10, 2010
Java’s toLowerCase() has got a surprise for you!
We generally use toLowerCase() on strings and write logic to perform some operations. But String.toLowerCase() has a catch. This method is Locale-specific.
If you do not need internationalization, to make it safer, you may use another method toLowerCase(Locale.English) and override the locale to English always.
Read this article on javapapers.com for complete details.
If you do not need internationalization, to make it safer, you may use another method toLowerCase(Locale.English) and override the locale to English always.
Read this article on javapapers.com for complete details.
Subscribe to:
Posts (Atom)