String[] array = {"A", "X", "G", "X", "A"};
Set set = new HashSet(Arrays.asList(array));
String[] array2 = (String[])(set.toArray(new String[set.size()]));
A set is a collection object that cannot have a duplicate values, hence converting the array to a set removes the duplicate values.
Monday, October 11, 2010
java.lang.UnsupportedOperationException on java.util.AbstractList
java.lang.UnsupportedOperationException: null
at java.util.AbstractList.remove(AbstractList.java:144) ~[na:1.6.0_04]
at java.util.AbstractList$Itr.remove(AbstractList.java:360) ~[na:1.6.0_04]
at java.util.AbstractCollection.remove(AbstractCollection.java:252) ~[na:1.6.0_04]
Arrays.asList(Object[]) returns type Arrays$ArrayList is of (extends) type AbstractList.
Arrays$ArrayList does not override remove(int) so the method is called on the superclass AbstractList
new LinkedList(Arrays.asList(String[] something));
Use any List implementation that supports a modifyable result. In the above, LinkedList works because, instantiates a new modifiable list using the immutible list created from Arrays.aslist(...).
at java.util.AbstractList.remove(AbstractList.java:144) ~[na:1.6.0_04]
at java.util.AbstractList$Itr.remove(AbstractList.java:360) ~[na:1.6.0_04]
at java.util.AbstractCollection.remove(AbstractCollection.java:252) ~[na:1.6.0_04]
Arrays.asList(Object[]) returns type Arrays$ArrayList is of (extends) type AbstractList.
Arrays$ArrayList does not override remove(int) so the method is called on the superclass AbstractList
new LinkedList(Arrays.asList(String[] something));
Use any List implementation that supports a modifyable result. In the above, LinkedList works because, instantiates a new modifiable list using the immutible list created from Arrays.aslist(...).
Saturday, October 09, 2010
Kapalabhati Pranayam.
This is my first non technical post. But is this really non-tech, no its a technical for body... none of us really cared about what our mind/body needs..
Spending 20 mins for our-self is not a big deal. You can do it early morning or before lunch or before dinner. We do spend lot of our time in social networking activities. Can we not steal some time (not more that 20 mins) and give our mind/body what it needs ?
*tip:
Morning after Kapalabhati take a glass of lemon juice in warm water. GFH :)
Kapalabhati can be done by siting in Padmasana or Sitting on chair in erect posture.
http://www.beautyandgroomingtips.com/2006/12/kapalabhati-pranayam.html
Spending 20 mins for our-self is not a big deal. You can do it early morning or before lunch or before dinner. We do spend lot of our time in social networking activities. Can we not steal some time (not more that 20 mins) and give our mind/body what it needs ?
*tip:
Morning after Kapalabhati take a glass of lemon juice in warm water. GFH :)
Kapalabhati can be done by siting in Padmasana or Sitting on chair in erect posture.
http://www.beautyandgroomingtips.com/2006/12/kapalabhati-pranayam.html
Subscribe to:
Comments (Atom)