Skip to content

Tag: arraylist

How to remove the brackets [ ] from ArrayList#toString()?

I have created an Array List in Java that looks something like this: When I print errors I get it errors as [1,2,3,4,5,6,7,8,9] Now I want to remove the brackets([ ]) from this array list. I thought I could use the method errors.remove(“[“), but then I discovered that it is just boolean and displa…

Adding null values to arraylist

Can I add null values to an ArrayList even if it has a generic type parameter? Eg. If so, will return 1 or 0? If I can add null values to an ArrayList, can I loop through only the indexes that contain items like this? Or would the for each loop also loop through the null values in the list?

How to sort dates of type string in java

I am building a android project where am storing some details which includes date as string,but now I need to sort the list view by date.I am bit confused on how to do it.I am done with everything but need to sort the list by date. Here is the overview of how am storing data. I have an arraylist of

Duplication on ArrayList Java

my title is bad but I don’t have an idea what it should be. My question is simple, I have four arraylist and I want to get similar words from two of them and put another arraylists. Anyway my array lists like; I tried this; But as you see arrList1 and arrList2 have duplicates so arrList4 will have same …