Skip to content

Tag: arraylist

Check if ArrayList Contains same array order ignored

I’ve initialized an ArrayList holding int arrays as such: ArrayList<int[]> holder = new ArrayList<int[]>(); If I add an int[] like this: int[] first = {1, 2, 3}; holder.add(first); If I do this check, I want the function to return true, but it returns false right now int[] second = {2, 1, 3}…

Decrease the number of calls

I have arraylist of filenames (java) and I want to delete these files using rm but it is time consuming can I do batching using xargs or something else which can help to delete files faster. Answer Don’t use rm. Use Java. As others have pointed out, spawning a process is much slower than doing it in your prog…

In an array of arraylists, get the largest arraylist

I have an array with multiple arraylists of different sizes. I want to find the index of the largest arraylist in the array. I tried this: disc being the name of the array of arraylists. ArrayList I believe doesn’t implement the Comparable interface so I can’t do it like this. Is there a way to ma…

Easy sort list 2D by column

I’m quiet new in Java data manipulation so I need some help if someone have a some good tips. Actually, I want just to find a easy way to sort a 2D list. I create a list like this: And then I want to have a result sorted by the second element like: I tried something like Arrays.sort(A.toArray(), (int[]a…

How can I convert arraylist to arraylist

My goal is to find on which specific index is String from ArrayList and add them to new ArrayList, So if house is [0] than i want to return new ArrayList with integer. At the begging I have ArrayList like this Input : And I want to get new ArrayList like this Output: Answer You can do it just by

How to iterate through ArrayList values of HashMap?

A question from a total newbie. Sorry. I have this customersOrders HashMap that takes String as keys and ArrayList<Double> as values. I need to find the total sum of orders for each customer and the maximum total sum in order to find the biggest customer. How do I manage to do that using just nested For…