collection « comparator « Java Collection Q&A

Home
Java Collection Q&A
1.algorithm
2.array
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
10.ArrayList
11.collection
12.comparator
13.Development
14.Garbage Collection
15.Generic
16.hash
17.HashMap
18.HashTable
19.iterator
20.LinkedList
21.List
22.Map
23.queue
24.Set
25.Sort
26.tree
Java Collection Q&A » comparator » collection 

1. Java Collections Sort not accepting comparator constructor with arg    stackoverflow.com

I'm getting a compiler error for this line: Collections.sort(terms, new QuerySorter_TFmaxIDF(myInteger)); My customized Comparator is pretty basic; here's the signature and constructor:

public class QuerySorter_TFmaxIDF implements Comparator<Term>{  
private int numberOfDocs;
QuerySorter_TFmaxIDF(int n){
   ...

2. Passing a comparator syntax help in Java    stackoverflow.com

I've tried this a couple ways, the first is have a class that implements comparator at the bottom of the following code. When I try to pass the comparat in ...

3. Why does the Java Collections Framework offer two different ways to sort?    stackoverflow.com

If I have a list of elements I would like to sort, Java offers two ways to go about this. For example, lets say I have a list of Movie ...

4. Direct comparator in Java out of the box    stackoverflow.com

I have a method which needs a Comparator for one of its parameters. I would like to pass a Comparator which does a normal comparison and a reverse comparator which does ...

5. Collections.max() Improper Arguments    stackoverflow.com

I'm simply trying to find the max of a list of "Officers". The specs of the assignment I'm working on don't allow me to make the Officers comparable, so instead I'm ...

6. How to define a Comparator in Java that compares based on two variables    stackoverflow.com

I want to create a comparator to operate such that a process with a lower arrival time will appear first in a sorting, and if two processes have the same arrival ...

8. Collections.sort won't work with custom comparator?    stackoverflow.com

import java.util.*;

public class ABC {
    public static void main(String[] args) {
        List<Integer> values = null;

       ...

9. How to sort a collection by a date field?    stackoverflow.com

I'm trying to sort an album by release date. For some reason I am not getting anywhere:

//sort by release date
Collections.sort(this._items, new Comparator<Album>() {
    public int compare(Album ...

10. Is there a implementation of retainAll() with custom Comparators?    stackoverflow.com

I need to sift Collections according to contents of other Collections. Usually, I would have used the Collection.retainAll() method.

Unfortunately, the equality of the domain objects I am handling is rather ...

11. Using a Comparator in Collections    coderanch.com

// Use a custom comparator. import java.util.*; // A reverse comparator for strings. class MyComp implements Comparator { public int compare(String a, String b) { String aStr, bStr; aStr = a; bStr = b; // Reverse the comparison. return bStr.compareTo(aStr); } // No need to override equals. } class CompDemo { public static void main(String args[]) { // Create a tree ...

12. Difference between Comparator and comparable in Collections    forums.oracle.com

i have been going through the collections chapter and i understand that to sort a collection(list or map or set)we need to use the Collections interface which has a compareTo method that takes in the list that we need to sort as its argument and for this we need to make the class in which we create the list to implement ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.