A Common interface to create an object that specifies the way of comparing other objects.

learn more…| top users | synonyms

-2
votes
0answers
12 views

Java Comparator.comparing() with String charAt() Function [duplicate]

I am learning the new Comparator.comparing() function.Here is the code I write to get a comparator for String to sort by the last char. To make the discussion simpler, here we just assume no null ...
2
votes
1answer
51 views

Compare objects by size of a Set attribute, with empty Set being left at the end of the sorted list

public class User {private String name;private private Set<MyEnum> enums;//getter and setter methods..}public enum MyEnum {A(1, "..."),B(2, "...");private ...
0
votes
1answer
14 views

Spring Integration: Using Priority-Channel with Comparator doesn't unpack message

I am using spring integration priority-channel and I wanted to provide a custom Comparator. <int:channel id="basedata.csv.income.sorting.channel" datatype="java.io.File"><int:priority-...
0
votes
0answers
23 views

List sorting based on another List's order Issue

I have a list of Strings named cardNameAndDescription in a class called GlobalDataHolderand i am sorting these Strings alphabetically with the Collections.sort(); method. However, each String in this ...
0
votes
0answers
17 views

Error: is not abstract and does not override abstract method compare() in java.util.Comparator

Firstly, I want to mention that I acknowledge question of the same title about this error, but I cannot solve my problem using existed answers.My program is simple. the program can sorts student by ...
0
votes
1answer
33 views

Java comparator get all unmatched fields

I have a class for comparing all the property values of an object with another using reflection api. The problem i am facing is, Here i am getting the name of those getter method's of the objects ...
0
votes
1answer
42 views

Java Comparator - Comparing 2 different objects in list

I have following class in Java, and I want to compare the tocompare objects in list with the previous tocompare object i.e compare t2 to t1. I am new to Java, so I don't have much knowledge about ...
1
vote
2answers
72 views

Properly sort equal items in Collection

According to Documentation Java SE7This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. Collections.sort(gpsDtoList, new Comparator<T>() {...
1
vote
1answer
54 views

How to use thenComparing in java stream

I have a map with strings as values. I want to sort it firstly by length, and if length of the strings is the same, i want to sort it alphabetic. I wrote those code : String out=outMap.values()....
0
votes
0answers
51 views

Comparison method violates its general contract : java

Below method throwing Exception :"Comparison method violates its general contract"Earlier it used to work perfectly fine, but all of sudden giving exception.public int compare(Review r1, Review ...
0
votes
1answer
57 views

fail to insert new elements to set when I add customized comparator

Here is my original code. I have two functions, add and print_out. "add" is used to update the times of a url by incrementing one every time when a user use that. And print_out just print all of urls ...
-3
votes
0answers
48 views

Having an issue with a constructor [duplicate]

This is not even close to that other question...I have a question on one of my programs, and not sure what to do. Here is my code so far: import java.util.EnumMap;import java.util.StringJoiner;...
-1
votes
2answers
82 views

Collections.sort() Comparison method violates its general contract in Java

I know that this kind of question has been asked millions of times if not billions, however I couldn't find my answer yet :)This compare() method doesn't have Long, Double, Float, ..., it only has ...
9
votes
2answers
125 views

Android - Is it possible to sort lists using Comparator.comparing instead of custom Comparators on APIs < 24?

I have a RecyclerView in the app I'm working on that I can populate with various items and search/filter/sort/so on. Currently working on sorting.I have multiple criteria that I can sort by, which ...
0
votes
1answer
29 views

ObservableList javafx sort descending with Comparator

ObservableArrayList.sorted works well with primitive data types but if instead reference datatypes can not workObservableList<NewClass> observableArrayList=FXCollections.observableArrayList()...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,