I have a class, which I have simplified to this:
final class Thing {
private final int value;
public Thing(int value) {
...
|
How can I fill up two vectors and combine them with eachother (either index or an object type in class). I guess if I use index to combine them, then the ... |
I'm writing some custom Comparators, and I'd like them to push null items to the bottom of the list, regardless of whether I'm sorting ascending or descending. What's a good ... |
I have an enum class like the following:
public enum Letter {
OMEGA_LETTER("Omega"),
GAMMA_LETTER("Gamma"),
BETA_LETTER("Beta"),
ALPHA_LETTER("Alpha"),
...
|
I learned how to use the comparable but I'm having difficulty with the Comparator. I am having a error in my code:
Exception in thread "main" java.lang.ClassCastException: New.People cannot be cast ...
|
How I can find line 4,1 and 6 in example below?
And is the use of Collection.sort() with Comparator reasonable in this case?
a - ...
|
As Java 5 have autoboxing, why I can't use Comparator to sort primitives? An int wouldn't be wrapped into a Integer?
|
|
I need to sorting function with custom comparator and swap function. I can write one myself, but I'm wondering if someone else didn't already do it. Java runtime contains many specialized ... |
I want to develop one sorting demo for car list. i am using data table to display car list. Now actually i want to sort the list by car color. here ... |
I have a Java PriorityQueue for sorting objects from a specific class I made called Node. I want it to sort the Nodes by their getData() method. I tried the following ... |
Sorry, I don't work with Java since a long time. I have a class which sort int type, and I am trying to do this, but this does not compile:
MySort.sort(vectorOfInt, new ... |
Hallo,
I am using the apache common LazyList (org.apache.commons.collections.list.LazyList). Now I'd like to call Collections.sort on this list, but I'm not sure if this is always allowed.
This kind of list produces a ... |
If I have the following class:
public class Employee {
private int empId;
private String name;
private int age;
public ...
|
I'm using Java Comparator for sorting in my code. How I can only sort by certain values, e.g., the values range from 1 to 1000, (default is 1000), but I only ... |
What will happen if I supply a non-transitive Comparator to Collections.sort? Can I run into infinite loop?
A small test I wrote produced an output, but I want ... |
I needed to implement sorting on all fields of my class
I wrote a comparator for each field in my class.
But I had to write a individual comparator for each field.
I ... |
I have a collection of beans OptionItemDTO (properties label and value) and I'm currently using something like this to sort by label:
Collections.sort(combo, new LabelComparator())
The problem is that it does not sort ... |
The Collections class can be used to sort Lists with a Comparator. The Arrays class can do the same for arrays. Is there a way to sort a TreeSet according to a different Comparator after it's already been created? Here is some sample code to help make clear what I'm asking. import java.util.Comparator; import java.util.Set; import java.util.TreeSet; public class TreeSetsAndComparable { ... |
I have a class that sorts with comprator, but i dosent work ! Any good ideas, look at my code ? Is there a better way to sort my list with objects ? package dk.jyskebank.jyskeinvest.backingbean.todayshighandlow; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Iterator; import java.util.List; import dk.jyskebank.j2ee.core.dao.DataAccessObject; import dk.jyskebank.j2ee.core.exception.JyskeSystemException; import dk.jyskebank.jyskeinvest.backingbean.BackingBeanHelper; import dk.jyskebank.jyskeinvest.backingbean.BackingBeanHelperImpl; import dk.jyskebank.jyskeinvest.dao.JdbcDaoFactory; import dk.jyskebank.jyskeinvest.dao.funds.FundDao; import dk.jyskebank.jyskeinvest.domain.funds.Fund; public class ... |
Hello. if anybody has a minute, i can't seem to get this sort working. i am sorting vector elements and want to use the date as the primary sort and type as a secondary sort. i thought i'd try something like this... String type="widget"; String date_string="25-MAR-2005"; SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); Date date_object = dateFormat.parse(date_string); long time_long=date_object.getTime(); String comparison_string=time_long+type; then compare ... |
|
Hello people! Here is my problem: I'm trying to sort arrays of these objects, Hotlap from the implementation below. They describe drivers' laps in a race qualify. I assume that the fastest driver is the one that spent less time to finish a lap, represented by totalTime. The point is: when they draw in totalTime, the fastest is the one with ... |
Hi All: I have an Employee.java class that has attributes: id, name age Is there a way to use the Java comparator to sort by age first, than with those employee with the same age sort by name and than those employees with the same name sort by Id using the comparator method in Java. Or does another has example or ... |
|
|
in my class i m using an array list that contain objectss(suppose of Songs class) now i want to sort this class that is in array list in some order . what i m doing is , sorting by implementing Comparator interface. now but the thing is this song class contain a hashMap also and based on the key in hashmap ... |
Hello to all, I need to implement a comparator that will take as input an object containing two longs, combine them and sort them in the form a.b, where a is the first long and b the second, first by a and then by b. (eg.1.2, 2.8, 1.5, 2.4, 3.4, 3.3, etc... becomes 1.2, 1.5, 2.4, 2.8, 3.3, 3.4, etc..) Is ... |
if(eDate1 == null || eDate1.equals("") || eDate2 == null || eDate2.equals("")) return ((String )stDate2 ).compareTo( (String)stDate1) ; else if ((arg0.getStartDate().equals(arg1.getStartDate()))) return -( (String )eDate1).compareTo( (String)eDate2 ); else return -( (String )stDate1).compareTo( (String)stDate2); } } If the input is: UnlawfulInfo ul1 = new UnlawfulInfo("20050601", "20050630"); UnlawfulInfo ul2 = new UnlawfulInfo("20050601", ""); UnlawfulInfo ul3 = new UnlawfulInfo("20050701", "20050725"); UnlawfulInfo ul5 = new UnlawfulInfo("20050701", ... |
|
|