Glitch in comparing elements of Integer array in java.

Правка en1, от shubhch32, 2019-03-08 19:46:50

I needed to sort elements for which I used Arrays.sort() function. I read somewhere that it sorts in O(nlogn) time only for arrays containing objects as elements (Integer, Double, etc. but not int, double). But when I was comparing elements in the array after sorting, it showed some weird behaviour. Comparing elements upto 127, it compares correctly but after that it gives wrong results. Any reason as to why?

Here is my code where seq[] is an Integer array (and not int seq[]):

if(seq[i]!=seq[i-1]) map.put(seq[i],count++);

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский shubhch32 2019-03-08 19:46:50 588 Initial revision (published)