CopyPastor

Detecting plagiarism made easy.

Score: 0.8131770697409797; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-12-01
by Satakshi Pandey

Original Post

Original - Posted on 2013-11-27
by Justin Civi



            
Present in both answers; Present only in the new answer; Present only in the old answer;

It also has something to do with the version of JDK. The implementation method in JDK 7 has been changed for which you are violating one of the 3 rules of compareTo method contract.
Look at this:
Description: The sorting algorithm used by java.util.Arrays.sort and (indirectly) by java.util.Collections.sort has been replaced. The new sort implementation may throw an IllegalArgumentException if it detects a Comparable that violates the Comparable contract. The previous implementation silently ignored such a situation. If the previous behaviour is desired, you can use the new system property, java.util.Arrays.useLegacyMergeSort, to restore previous mergesort behaviour.
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
It also has something to do with the version of JDK. If it does well in JDK6, maybe it will have the problem in JDK 7 described by you, because the implementation method in jdk 7 has been changed.
Look at this:
Description: The sorting algorithm used by `java.util.Arrays.sort` and (indirectly) by `java.util.Collections.sort` has been replaced. The new sort implementation may throw an `IllegalArgumentException` if it detects a `Comparable` that violates the `Comparable` contract. The previous implementation silently ignored such a situation. If the previous behavior is desired, you can use the new system property, `java.util.Arrays.useLegacyMergeSort`, to restore previous mergesort behaviour.
I don't know the exact reason. However, if you add the code before you use sort. It will be OK.
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");

        
Present in both answers; Present only in the new answer; Present only in the old answer;