Skip to content
Advertisement

Tag: list

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, int[]b)

Rearrange substrings using two criteria [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago. Improve this question Given a String: I need to sort its substrings first by numbers (in descending order) and then by letters, so

Remove numbers from a list that begins with a specif digit

For example, i have this list How i remove only the numbers that begins with “6” Answer There are several ways how you can approach this task: using an Iterator; by utilizing so-called traditional for loop; with a help of Stream IPA; using method Collection.removeIf(). Note that attempt to address this problem using enhanced for loop (sometimes called “for-each” loop)

Java Filter one stream based on another stream and collect

I have this code working with a for loop and steam, but I was wondering I can improve it using two streams. Here I want to replace the for loop with a stream and would like to get a list of String that the method returns. Answer I was able to find a quick and dirty solution, of course not

Java remove dupplicate attribute in List

I have list of message, class Message have 2 attribute: The following code below: I want to remove duplicate message from list but must keep the message with the longest time in List Input Expect result Answer This will solve your issue. P.S – plz go through basic data structures available in Java and their use cases.

How to i compare two lists of different types in Java?

I have two lists: The first list is a list of MyObject which contains an int and a String: The second list is simply a list of strings: I want to compare the list of strings (personList) with string in the list of MyObject (myObjectList) and return a list of id’s with all the matches. So in the examle it

Advertisement